Firefox“错误加载脚本"在 FF2 中加载 Google Analytics [英] Firefox 'Error loading script' loading Google Analytics in FF2

查看:15
本文介绍了Firefox“错误加载脚本"在 FF2 中加载 Google Analytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理的项目使用 window.onerror 事件处理程序来报告用户问题.我注意到一个用户似乎无法加载 Google Analytics 脚本.我们的网站没有看到很多流量,所以我不确定这有多普遍,但到目前为止它似乎只影响了一个用户.

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.

他的用户代理是:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17".
Firefox 给出的错误消息是:错误加载脚本".

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".

附加说明:该站点引用了其他几个 javascript 文件.但是,分析引用是唯一指向外部域的引用,并且是页面底部、就在结束正文标记之前的唯一脚本引用.

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!

推荐答案

在所有脚本加载完成之前离开 Firefox 中的页面时,会出现此问题.所以我认为忽略错误是安全的.

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.

您不会在 Firefox 错误控制台中看到此错误,但您可以通过将警报绑定到 window.onerror 事件来使其可见.然后你就可以在短时间内看到警告框,并在错误控制台中得到以下错误:

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]

我正在使用以下检查在我的 onerror 处理程序中忽略此错误:

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;
}

这篇关于Firefox“错误加载脚本"在 FF2 中加载 Google Analytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆