无法从释放的脚本中执行代码-IE6 IE7 IE8 IE9 [英] Can't execute code from a freed script - IE6 IE7 IE8 IE9

本文介绍了无法从释放的脚本中执行代码-IE6 IE7 IE8 IE9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天在IE6中遇到了这个问题(但在所有最新版本的IE中都可以重现).

I ran into this problem today in IE6 (but is reproducible on all recent version of IE).

我注意到有很多人遇到了这个问题,但还没有找到解决该问题的非常实用的方法.

I noticed quite a few people run into this problem and I haven't seen a very practical way to fix this.

关于HTML文档开头的脚本标签和元标签的顺序,似乎还有其他解决方案.我还没有确认,但是无论如何这是一个链接:导致错误的原因无法执行"释放脚本中的代码"

There seems to be some other solution floating about regarding the order of script tags and meta tags in the head of the HTML document. I haven't confirm this but here's a link anyway: What causes the error "Can't execute code from a freed script"

我也知道该问题的解决方案,所以我将其发布在下面

I also know the solution to this problem so I'm posting it below

推荐答案

首先,您需要找到消息的来源.

First of all you need to locate the source of the message.

IE以其糟糕的错误报告而闻名,但幸运的是IE9似乎有些能力.如果此错误发生在IE6,IE7或IE8中,它也会在IE9中发生,所以请使用IE9进行调试(出于您的理智)

IE is known for it's abysmal error reporting but luckily IE9 seems somewhat capable. If this bug occurs in IE6, IE7 or IE8 it will also occur in IE9, so use IE9 to debug (for your sanity)

在IE9中打开Webdeveloper控制台(按F12键),然后逐步执行该步骤以产生此错误.

Open the webdeveloper console in IE9 (press F12) and run through the steps to produce this error.

IE9现在应该在控制台上为您提供文件和行指示,是的!

IE9 should now give you a file and line indication on the console, yay!

通常出错的是在setTimeout或Ajax请求的延迟下执行的回调.如果在其中定义了回调的窗口,文档或框架被卸载,那么当它尝试执行回调函数时,您将收到此消息.

What typically goes wrong is a callback that is executed after some delay, either by setTimeout or because of an Ajax request. If the window, document or frame the callback is defined in got unloaded then you will get this message when it tries to execute your callback function.

貌似其他浏览器都忽略了这个问题,我想这很好.为了使IE做到这一点,只需将回调包装在try-catch块中(我不知道回调的计算结果,我认为它的计算结果未定义).如果您想进行更精确的错误处理,或者如果您真的想在发生这种情况时采取措施,则可以这样做,请在此处发布信息,因为我很好奇哪种用例实际上需要这样做.

Seemingly other browsers ignore this problem, which is fine I guess. To make IE do the same just wrap the callback in a try-catch block (I don't know what the callback would evaluate to, I don't think it evaluates to undefined). If you want have more precise error handling or if you actually want to take action when this occurs you can probably do so and please make a post here because I'm curious as to what kind of use case would actually require this.

这篇关于无法从释放的脚本中执行代码-IE6 IE7 IE8 IE9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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