Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox 'Error loading script' loading Google Analytics in FF2

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!

like image 963
AgileJon Avatar asked Oct 10 '08 18:10

AgileJon


1 Answers

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;
}
like image 95
Karl Bartel Avatar answered Sep 28 '22 06:09

Karl Bartel