Firefox 'Error loading script' loading Google Analytics in FF2 - javascript

The project I'm working on uses a window.onerror event handler to report user problems. I've noticed a single user that just cannot seem to load the Google Analytics script. Our site doesn't see a lot of traffic so I'm not sure how widespread this is, but so far it seems to just effect one user.
His user agent is: "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17".
The error message Firefox gives is: "Error loading script".
Additional note: The site references several other javascript files. However, the analytics reference is the only one to an external domain and the only script reference at the bottom of the page, just before the closing body tag.
Has anybody else run across this, or have any idea what could be the issue? Thanks!

This problem occurs when leaving a page in Firefox before all scripts have finished loading. So I assume that it is safe to ignore the error.
You don't see this error in the Firefox error console, but you can make it visible by binding an alert to the window.onerror event. Then you will be able to see the alert box for a small amount of time and get the following error in the error console:
[11:35:57.428] uncaught exception: [Exception... "prompt aborted by user" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource:///components/nsPrompter.js :: openTabPrompt :: line 462" data: no]
I'm using the following check to ignore this error in my onerror handler:
if (navigator.userAgent.search('Firefox') != -1 && message === 'Error loading script') {
// Firefox generates this error when leaving a page before all scripts have finished loading
return;
}

This is a rather random guess, but I wonder if the user is using an add-on like NoScript to control script execution and is not allowing scripts from Google Analytics to run. I know this is possible because it's what I do :) I don't know if that would show up as the error you're seeing.

I have a site with over 80 pages, all that employ JavaScript error trapping. My site serves well over 2000 pages a day and I get about ten "Error loading script" scripting errors each day from Firefox browsers. It is beginning to really annoy me and I am becoming convinced that it is a problem in Firefox.
I can discount the NOSCRIPT suggestion because the script loads in the head of my pages where there are no NOSCRIPT tags.
I can discount the 'external domain' suggestion because I have two sites that suffer this problem and in both cases the JS library files are located on the sites own server.
I have carefully checked every library file and web page using JavaScript Lint and I have discovered scripting errors and questionable scripting techniques. All these problems have been corrected but this has not provided any sort of cure to the "Error loading script" problem.
My pages do load several JavaScript library files that do not have this problem and the only difference is the size of the files. Most of the files are under 5KB but the problem file is 17KB.
Could the size of the library file be the problem?
Aagh!

We had the same issue and after examining our CDN logs, we discovered that Firefox triggers the onerror event when a script returns with HTTP status "304 Not Modified", so a cache hit. In fact, Firefox (tested with Firefox 12 at time of this writing), seems to trigger onerror event for all HTTP statuses except '200 Ok'. Other browsers behaved differently in our experiment: Chrome (19) triggered onerror only on '407 Proxy Authentication Required' and Opera (12) on 100, 101, 204, 4xx and 5xx.

I'm sure this is long resolved.. but to anyone who stumbles across this page: this error is triggered by firefox when an external script fails to load (it's easy to find the code that triggers this in the source code). We were catching these errors on our site and it turned out that we were returning 404s for the script, so I suggest looking at your logs as one possibly source of this error.

Related

How to prevent IE11 response to network errors

My javascript application has its own error handling (and UI support) for dealing with comms errors with the server. For testing, I'm inducing comms errors by simply severing the network connection (turning off the wifi).
All good in Chrome/Safari... IE 11, however, will replace my content with its own network loss messages, like "This page can't be displayed" (i.e., shows dnserrordiagoff.htm). This is, in short, annoying and undesired. Is there any way to suppress it?
Bonus: Firefox 43 is kind enough to replace my content with a blank/empty window. Any thoughts?
Thanks all, -Pete

Error with HTML/iframe in FireFox - Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHistory.pushState]

I am creating a small javascript simulation of a java-based (JSF) server. The bootstrap javascript file will download and parse a bunch of files using AJAX, and then generate a large HTML string. This HTML string is a full HTML document - it has a doctype, head, script includes, inline scripts, body, etc.
The reason I do not want to use the real JSF back-end is because I would like to be able to have a pure UI environment to test my code without any java/oracle server slowing me down.
I want to share my code (in a .zip file for example) with anyone and they should be able to open the page (with a small loading screen while the AJAX calls are made) in any browser without some server already installed on their machine.
The answer to that question led me to explore more - now I've run into a different error but I cannot seem to explain it.
Fiddle #1 : This one attempts to put the HTML into an iframe using the iframe's document.write. In this HTML there is a script that pushes a new history state history.pushState(null, null, hash)
Fiddle #2 : This one attempts to put the HTML into the iframe, but this time it just uses location.hash = hash
Both fiddles seem to work fine in Chrome and Safari and IE 9 - but Firefox gives the following error:
NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHistory.pushState]
I don't understand this error - if you do this same code history.pushState(null,null,"#test") on any page in firefox using the javascript console in FireBug it works fine - but in this particular situation it doesn't work.
I also tried to perform document.open(); document.write(html); document.close() on the document in the current page (instead of creating an iframe), but the same problem happened - only this time if I put break points in firebug into javascript code inserted in the HTML fragment, the breakpoints don't work which would mean I could no longer debug anything in firefox. At least with the iframe approach, the breakpoints work.
Can anyone shed some light into this problem?
Here is another related question that I asked yesterday which lead to finding this error: Firefox Fail - After using document.write and update to location.hash causes page refresh
You can put this code
history.pushState(null,null,"#test")
before
document.open();
document.write(html);
document.close();
I have run into a similar issue trying to open an Ember app using history.pushState (Ember Router location: 'history' method of routing) inside an iframe. It appears the issue only occurs when doing a hard refresh (cmd + shift + r on Mac or ctrl + f5 on Windows) in Firefox. The issue only occurs for me in FireFox, works fine in Chrome and Safari with similar hard refresh.
The issue does not occur for me when navigating to the page for the first time or when normally refreshing the page (cmd + r Mac, f5 Windows). I have found many seemingly related on Bugzilla for Mozilla but many are close. This one seems to represent the same issue I am having and is still open as of current versions of Firefox (v37.0.1 at time of writing).
https://bugzilla.mozilla.org/show_bug.cgi?id=1003100

Replace url from youtube to embed code - Error: Permission denied to access property 'toString'

I have this code and this error in FireBug:
Error: Permission denied to access property 'toString'
How can i fix this error?
HTML:
<div class="yturl">http://www.youtube.com/watch?v=UNMLEZrukRU</div>
JS:
$("div.yturl").each(function(){
var regex = /(\?v=|\&v=|\/\d\/|\/embed\/|\/v\/|\.be\/)([a-zA-Z0-9\-\_]+)/;
var youtubeurl = $(this).text();
var regexyoutubeurl = youtubeurl.match(regex);
if (regexyoutubeurl)
{
$(this).html("<iframe width=\"390\" height=\"315\" src=\"http://www.youtube.com/embed/"+regexyoutubeurl[2]+"\" frameborder=\"0\" allowfullscreen></iframe>");
}
});
DEMO: http://jsfiddle.net/9e48p/
The error can either be fixed by Adobe's Flash Player team, or by the Google engineers - you should just ignore it for now. It's connected to Flash Player security settings and the SWF file embedded into the Youtube page. The problem has been reported in the past by IBM, and there is a Mozilla Bugzilla entry as well.
When I deactivate Flash Player in Firefox 16.0.2, the error message disappears. Check comment #37: https://bugzilla.mozilla.org/show_bug.cgi?id=434522#c37
For what it's worth, I'm seeing this bug happen when any flash file,
even ones that have NO actionscript calls (ExternalInterface, etc) in
them at all, is loaded into an iframe on a page where the page domain
and the iframe domain are different. This means that the iframe
problem is caused when there is in fact a cross-domain situation in
place. However, it's not totally clear if there's really actually
attempting to be a cross-domain call that should be prevented and
error'd out.
Because it's nothing that the flash SWF itself is trying to call to do
"Location.toString", and it's nothing about the javascript on the page
doing it, the only choice is that there's something about the flash
plugin itself (9.0.124 is what I'm testing with) that's trying to make
that call up to the parent/top window to do Location.toString().
While the bug is marked as resolved, the test case attached https://bug434522.bugzilla.mozilla.org/attachment.cgi?id=321956 produces the same error message in the latest Firefox version (both in the Firebug console, or the Firefox Error Console window).
Update:
The bug has been filed with Adobe as well in the old bug database: FP-561 "Location.toString" uncaught (security) exception caused by improper Flash plugin behavior (you need an account to see the bug details). The last comment there when the bug was closed:
Tested with the latest Flash Player 10.3.181.34 on Firefox 4 and 5, no
such exception was thrown. So the bug may have been fixed, right? If
you still meet this issue, please file a bug in our new bug system
https://bugbase.adobe.com/ and put a link in the new bug to this
original JIRA report. We are happy to follow up your report in the new
bug system.
Don't ignore this error just because its not related directly to your code.
It seems to occur when your embed is initialy hidden.
Just add ?html5=1 to your embed url. IE8 will still take flash version. or load your video with the Youtube api.
Something is likely wrong with your Iframe url constructor. The error is being thrown in a youtube script that loads in the Iframe. The same error gets thrown with a harcoded html Iframe that isn't dynamically added with your script
<iframe width="390" height="315" src="http://www.youtube.com/embed/UNMLEZrukRU" frameborder="0" allowfullscreen></iframe>
HTML version only demo http://jsfiddle.net/Lgt5f/
Double check the url isn't missing a parameter , otherwise I would check youtube support resources
That issue can be caused by an extension that isn't working properly.
Start Firefox in Troubleshoot Firefox issues using Safe Mode to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
Ignore that error, it's not related to your code. Just a browser bug.

/undefined appearing lots of time in my 404 error log

Basically in my error log i see lots of:
mysite.com/undefined (with referer coming from random pages of the website)
User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
(and some other user agent)
I have of course checked HTML or DOM for links with /undefined or something like that and there is just nothing. I have checked network tab with developer tools and on those page nothing requests /undefined (with my chrome).
I have then setted a javascript logger to save any error that come up. And in the log there isn't nothing that throws undefined or something like that...
This is driving me crazy. Of course if i go on tihs page with my chrome, javascript doesn't print any error
Notice: i have read everything here
Edit
Notice2: Beside that javascript error logger I have added an eventlistener (as explained in the answer linked)
$("body").on("click", "a[href$='undefined']", function() {
window.onerror('Bad link: ' + $(this).html()); //alert home base
});
And this never get triggered. (I have tested it with a manual /undefined link and the logger works)
Also I found this topic on google groups. Webmaster there are experiencing the same problem but no one has managed to nail down to the cause.
Maybe it's some extension on chrome or any other browser that causes this requests.
Presumably you are using window.onerror and logging an error in that function.
If a javascript error happens on a different domain (e.g. from some social buttons, an iframe, a cross-domain javascript, or possibly a browser extension), window.onerror could actually betray sensitive information in the error report. So for security reasons, cross-domain errors will still call the function, but all the parameters (including the url) will be undefined, and the message will just be a generic "Script error." I would guess you are having cross domain errors, and they're being logged as undefined.
Take another look at that Google Group thread you linked to. Just recently one of the members managed to figure a way to disable the plugin/malware that appears to be causing the errors:
To disable the malware and stop "undefiend" requests, apply this to
every page with a search field on your site:
<script type="text/javascript">
window.suggestmeyes_loaded = true;
</script>
It sounds like this is most likely an ajax request using "/" + variable and variable happens to be undefined instead of say user. Are you using a library for your AJAX calls? perhaps you could try to catch the invalid url in there as well.

(NS_ERROR_DOCUMENT_NOT_CACHED) through firefox same code works for safari

I am getting (NS_ERROR_DOCUMENT_NOT_CACHED) error when I try to access the Javascript code through firefox.I get this error in the contents tab of HTTPFOX.
I googled and set the parameters of browser in config file as specified in this site but it still doesn't work.
http://code.google.com/p/httpfox/issues/detail?id=20
Can somebody suggest whats going wrong since the same code works fine for safari browser..
If anyone is interested in a solution to this, I believe it's to do with the plugin noscript. Disabling it fixed this, but I have yet to work out what part of noscript was causing the issue. Will update if I find out.
Edit:My issues was with a twitter auth callback. In the Advanced settings of noscript under ABE, in the SYSTEM ruleset, on the line "Accept from LOCAL" I added "*.twitter.com". This allowed callback requests from *twitter.com to return to a local address.
On my macbook I had to uninstall firefox completely to correctly get the content of an ajax response with httpfox. This also implies to remove the firefox profile bij removing this Firefox folder (I could only find it via the terminal and not via Finder):
/Users/<YOURUSER>/Library/Application Support/Firefox
Then install firefox again and install the httpfox add-on.
I tried many cache settings also by entering about:config in the firefox URL however without succes. Be aware that removing the profile settings like I describe will also remove all your personal firefox customization. It concerned firefox 18.0.2 and httpfox 0.8.11.
We used to get the same error when our JavaScript made an XMLHTTPRequest to the server. On the server side, we had java, and the java response, the content type was not explicitly set to "text/html". When that was done
resp.setContentType("text/html");
the error went away.

Categories