Can't execute code from a freed script - IE6 IE7 IE8 IE9

ε祈祈猫儿з 提交于 2019-11-29 10:16:13

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

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)

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

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

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.

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.

If you have page that uses several Frames, this error might be caused by objects initialized in one frame being used in some other frame after the initial frame was removed from the page.

When that happens, then depending on situation, you might want to:

  • Review your code looking for potential memory leaks
  • If those object represent some data you do actually want passed between frames, then consider using their stringified form instead.

The solution - be sure to place all META statements BEFORE any script statements.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!