I'm loading a page through AJAX with jQuery's load() function. It doesn't work in IE8, giving the "permission denied" error. Using the IE debugger, it seems that when jQuery tries to open up the xhr, ie blocks it.
The problem is, my page has a javascript src that points to bing maps js api (which of course is in a completely different domain than mine). It seems to me that IE tries to grab this js file through a xhr, which then throws the "permission denied" error. Is there a workaround for this?
I can only remember of downloading the bing maps js myself and serving them locally.
I did more test on this. And seems the error was caused by invalid HTML structures on the page. As it is a very complicated page, there are mismatched open <div> or <table> on the page, as when I shorten the page to bare minimum, it works on IE as well. But I don't understand why it was not working when you get to the page first time, and if you refresh the page, it will work after that.
I just had this problem and I posted my solution on this thread:
jQuery AJAX problem in IE7 (possibly other versions as well)
I eventually grabbed a copy of the script and include it myself, so it is in the same domain.
You could include the script tag to the Bing Maps API in the parent document (the one making the jQuery load() call).
Just for the reference:
I experienced this error on Windows 8 with IE 10 inside my WinForms application.
In this application, I'm hosting a WebBrowser control that loads its content from a built-in web server and also communicates via window.external with my host WinForms application.
Enough keyword fishing.
Getting this error
Now what happens to get this jQuery error in my application was:
Browser has successfully loaded an URL.
I programmatically loaded another URL.
Then I immediately opened a child form with Form.ShowDialog.
After closing this form, the jQuery error was shown.
Resolving this error
I resolved the error by postponing the opening of the child form until the application was idle.
I.e. I used a Queue list inside my main form, subscribed to the Application.Idle event and inside this event handler, I processed the queue, one by one.
The new steps now were:
Browser has successfully loaded an URL.
I programmatically loaded another URL.
Put the action to open the child form inside the idle queue.
When the idle queue is processed, it opens the child form.
Then, the error was gone.
I guess, instead of using this idle processing, I also could have waited until the web browser finished its loading by subscribing to the DocumentCompleted event and show the child dialog from there.
Hope this will help someone...
Related
I am using Django v1.10 for an application where in need to send an API call just before browser close through crude javascript (don't want to use any library for sake) preferably. I've read about window.unload and window.onbeforeunload. The first one didn't seem to work at all. The second can work but it also gets executed when there is reload or redirection to another page (it works as it should but that is what I don't want). I've tried using SESSION_EXPIRE_AT_BROWSER_CLOSE of Django which works only when a user has totally exit out of the browser (no browser process running). I've also seen answers on the web where people have suggested to open another window/tab of the browser through JS as the tab closes.
So in precise words, I want to make an API call just before browser tab close (not in any other situation).
Please help!
I have a basic HTML website (with some javascript) using a simple anchor tag to download a file like so:
Mexml Samples 1.0
In order to track the number of downloads, I have an onclick handler that passes an event to Google Analytics like so:
$('#mybutton').click(function(e){ga('send','event','Download','MexmlSample','MexmlSample-1.0');});
This works as expected when downloading the file using Chrome on OS X, and IE on Windows 7. The file downloads and I see the event in my GA account.
When I test it in Safari 8 on Yosemite, the file does download, but GA only rarely sees the event. And of course I get the dreaded Failed to load resource: Frame load interrupted in the Safari error console.
I assume that I get the GA event sometimes because of a race condition between when Safari interrupts the action and when the GA code fires.
So can anything be done to fix this in Safari so that I always get the GA events?
Note that my question probably has the same root cause as this unanswered question: Frame load interrupted when downloading excel files
Update June 6
I am now thoroughly confused. I just noticed that if I open up a new browser page to my site (in Safari), and click on the download, then it gets logged by GA. However subsequent clicks download still the file, but don't get logged by GA.
If I close that window, and open a new one, then again the first download gets logged by GA.
In contrast, when using Chrome every download gets logged by GA.
I am now thinking that I may be looking at the wrong problem. The behavior I am seeing is telling me that Safari is maintaining a state in JavaScript that allows the first GA call to go through, but blocks all subsequent calls.
But this is the same code being run by Chrome, so I don't know where to how to even start debugging the problem.
If you always want to get the ga event then the hitCallback is likely the only way to go until whatever is wrong with Safari is fixed. I use a similar pattern to send a GA event from a page in an app which is just a redirect after a whole load of database stuff has been executed in rails. There is no noticeable lag from adding the javascript redirect into the callback. However I am not sure how to initiate the download from javascript off the top of my head.
ga('send','event','Download','MexmlSample','MexmlSample-1.0', {
hitCallback: function(){
initiateDownload();
})
I am not aware of any need to use the setTimeout() for pattern in this instance.
The only solution I can think of - is waiting till GA request will finish, and only after that set location.href to desired file download link. But this is not really good from user's perspective. (This can be achieved with hit callback https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitCallback).
Probably HTML5 download attribute for href will solve the problem.
I have no OSX with safari to test, so this is only my thoughts.
In my application i am getting the content of some other domain's page. Along with the content it is running the javascript associated with the particular page. In the javascript code "document.selection.createRange()" is written which is throwing exception at run time in IE (since in IE due to security concern you can't change iframe's data or the reverse).
So my question is how to suppress the exception.
Thanks in advance :)
You can do this in jQuery by using a load with a page fragment.
If .load() is called with a selector expression appended to the URL,
however, the scripts are stripped out prior to the DOM being updated,
and thus are not executed
Be aware though that this will only work if the other domain allows your domain access via CORS http headers.
I am a beginner web developer and here is my problem:
In short:
I keep getting similar message in Firebug for all the javascripts I include in the page:
GET http://localhost.:33085/Scripts/jquery.form.js?_=1284615828481 200 OK 1.01s
In details:
I am loading a webpage using AJAX . This page contains references to some java scripts. It also contains some embedded javascript code. Firefox keeps reloading the referenced java scripts each time I navigate to these pages which seems to take time. My questions are:
These scripts are already referenced in the page that has the where I load this page using AJAX. if I remove the references from this ajax loaded page, I start getting '$ is not defined'. Is there away to avoid that error other than referencing these scripts in the AJAX loaded page?
How can I stop firefox from reloading those pages and start using cached version?
Why is it so slow on firefox? I don't seem to see such perf issues on IE or Chrome?
Thanks
The best approach is to ensure that the initial page that you first access loads the required scripts and then subsequent ajax requests only load the content that you need (i.e. the references to the scripts is not in the html returned by the ajax request). There are server side frameworks to help you achieve this but without knowing your server technology I cant recommend a specific solution.
Firefox may be slow due to Firebug, with full debugging enabled in firebug it can slow you web pages down.
So all this time I had no problem with this script. But all of sudden today, it began to behave strangely.
So I have a JavaScript page that loads inside an iframe.
This is injected into a page loaded via proxy.
$(top.document).ready(), throws an error saying Permission denied...
I was surprised, so I decided to try load a different page.
Then it was no longer complaining.
I rebooted my computer, and when I first loaded a page via proxy, as the iframe containing JavaScript was injected into that page, I got the same error again.
What is happening? Is this a problem on my server or my computer?
http://en.wikipedia.org/wiki/Same_origin_policy
As the error says, there is a permissions problem and it likely has nothing to do with an error your computer, server, or otherwise, but is a design limitation/security feature of JavaScript.
JavaScript is able to access and/or alter other documents (e.g.: windows) other than its own (the one it is being executed fro) if that document comes from the same host. This is known as the "same origin policy."