错误:尝试在已清除的范围内运行编译并执行脚本

发布于 2024-10-26 18:47:13 字数 348 浏览 4 评论 0原文

自从升级到 Firefox 4.0 以来,我注意到控制台中偶尔会出现错误:

尝试在已清除的范围内运行编译并执行脚本

目前我在网上能找到的关于此的唯一信息是mozilla groups forum,其中建议与会话恢复有关。就我而言,虽然我无法可靠地重现该错误,但它随时都会发生,而不仅仅是在恢复之后。

这是怎么回事?我该如何停止错误?

Since upgrading to Firefox 4.0, I've noticed that I'm occasionally getting an error in the console stating:

attempt to run compile-and-go script on a cleared scope

The only information I can find about this on the net currently is on the mozilla groups forum, where it is suggested that it's something to do with session restoring. In my case, though I haven't been able to reliably reproduce the error, it happens at any time, not just after a restore.

What's the deal? How do I stop the error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

娇纵 2024-11-02 18:47:14

我注意到,如果禁用缓存,我将不再在控制台中收到此错误。

I have noticed that if I disable the cache, I no longer get this error in the console.

烏雲後面有陽光 2024-11-02 18:47:14

如果 Firebug(在我的例子中是 1.8)被禁用,则不会发生该错误。

The error doesn't occur if Firebug (in my case 1.8) is disabled.

夏雨凉 2024-11-02 18:47:14

检查您的代码是否有重复的元缓存控制并删除其中之一:

<meta http-equiv="cache-control" content="no-cache" />

Check your code for duplicated meta cache-control and remove one of them:

<meta http-equiv="cache-control" content="no-cache" />
只等公子 2024-11-02 18:47:14

我也遇到了这个问题,但我重新安装了 FireFox。

之后错误就消失了。

i had this problem too but I did a clean re-installation of FireFox.

after that the error was gone.

清醇 2024-11-02 18:47:14

当我尝试在从同一域 iframe 附加的元素上添加事件时,出现此错误。添加了clone()并且错误停止了。

I got this error when I tried adding events on elements appended from a same domain iframe. Added clone() and errors stopped.

初吻给了烟 2024-11-02 18:47:14

与萤火虫无关。当萤火虫被禁用时它“消失”的原因是你不再看到异常。原因是有一个处理程序附加到一个现在为空但未正确清理的事件。您需要确保正确处理该处理程序,否则该事件仍会触发对处理程序的引用。

It has nothing to do with firebug. The reason it "goes away" when firebug is disabled is that you are no longer seeing the exception. The cause of this is having an handler attached to an event that is now null but not properly cleaned up. You need to make sure that handler is properly disposed of, otherwise the event still fires the reference to the handler.

以往的大感动 2024-11-02 18:47:14

它是:菜单Firebug->控制台->显示 Chrome 错误

关闭,故事结束;)

It is: menu Firebug -> Console -> Show Chrome Errors

switch off, end of story ;)

不爱素颜 2024-11-02 18:47:13

对我来说(Firefox 11、Firebug 1.9.1),当调试器在断点处暂停时,刷新页面(F5 或 CTRL+F5)后有时会发生这种情况。

解决方案似乎是继续执行脚本,并且仅在 Firebug 暂停时刷新页面

For me (Firefox 11, Firebug 1.9.1) it happens sometimes after I refresh the page (either F5 or CTRL+F5) while debugger is paused on a breakpoint.

The solution seems to be to continue the execution of the script, and refresh the page only when Firebug is not paused.

请叫√我孤独 2024-11-02 18:47:13

就我而言,是 document.write 方法在 Windows 上的 Firefox 4、5、6 上导致了问题。 Linux 版本不受影响。我要做的就是覆盖 document.write 方法。

我知道现在不应该使用 document.write,但是 deployJava.js(Sun/Oracle 编写的标准 Java Applet 部署脚本)正在使用它。 Google 在 Google AdSense 广告中使用它。 document.write 无处不在。

<script>
    var documentWriteOutput = '';
    var got = document.write;
    document.write = function(arg) { documentWriteOutput += arg; }
</script>
<script src="badScriptThatIsUsingDocumentWrite.js"></script>
<script>
    runBadScriptThatIsUsingDocumentWrite();
    document.write = got;
    // Do whatever you want with the documentWriteOutput
    // e.g. $('#somewhere').html(documentWriteOutput);
</script>

我希望这有帮助。然而,我在互联网上看到了很多对我不起作用的“解决方案”。这可能意味着“尝试在已清除的范围内运行编译后执行脚本”是 Firefox JavaScript 引擎问题/错误。

In my case, it was document.write method causing the problem on Firefox 4, 5, 6 on Windows. Linux versions are unaffected. What I had to do is to overwrite document.write method.

I aware that document.write shouldn't be used these days, but deployJava.js, a standard Java Applet deployment script written by Sun/Oracle, is using it. Google is using it in Google AdSense ads. document.write is everywhere.

<script>
    var documentWriteOutput = '';
    var got = document.write;
    document.write = function(arg) { documentWriteOutput += arg; }
</script>
<script src="badScriptThatIsUsingDocumentWrite.js"></script>
<script>
    runBadScriptThatIsUsingDocumentWrite();
    document.write = got;
    // Do whatever you want with the documentWriteOutput
    // e.g. $('#somewhere').html(documentWriteOutput);
</script>

I hope this helps. However, I saw lots of "solutions" on the Internet that didn't work for me. It may mean that "Attempt to run compile-and-go script on a cleared scope" is a Firefox JavaScript engine problem/bug.

回心转意 2024-11-02 18:47:13

我注意到,如果在文档完成加载后使用 document.write 写入文档(例如,在从 JQuery 的 $(document).ready() 方法调用的函数中),则可能会发生此错误。当这种情况发生时,Firefox 似乎会丢弃旧文档并编写新文档。我不知道这是否是新行为。似乎当您尝试对旧文档进行操作(例如使用 JQuery 选择器)时,您会收到此错误。对我来说,修复有问题的脚本以在文档加载后不调用 document.write 修复了错误。

I've noticed that this error can happen if you write to the document with document.write after the document has completed loading (e.g. in a function called from JQuery's $(document).ready() method). When this happens, it seems that Firefox discards the old document and writes a new one. I don't know if this is new behavior or not. It seems that when you try to operate on the old document, e.g. with JQuery selectors, you get this error. For me, fixing the script in question to not call document.write after the document had loaded fixed the error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文