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

3

8

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

Brisling answered 28/4, 2011 at 0:12 Comment(0)
B
16

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.

Brisling answered 28/4, 2011 at 0:18 Comment(0)
C
0

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.
Custodial answered 25/1, 2017 at 17:20 Comment(0)
C
-2

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

Colourable answered 25/5, 2012 at 18:19 Comment(1)
Dit you test it yourself? Or is this copied from another website? I have no meta tags at all and I still get this errorPredacious

© 2022 - 2024 — McMap. All rights reserved.