Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

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

like image 390
Halcyon Avatar asked Apr 28 '11 00:04

Halcyon


1 Answers

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.

like image 50
Halcyon Avatar answered Oct 04 '22 16:10

Halcyon