Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes the error "Can't execute code from a freed script"

I thought I'd found the solution a while ago (see my blog):

If you ever get the JavaScript (or should that be JScript) error "Can't execute code from a freed script" - try moving any meta tags in the head so that they're before your script tags.

...but based on one of the most recent blog comments, the fix I suggested may not work for everyone. I thought this would be a good one to open up to the StackOverflow community....

What causes the error "Can't execute code from a freed script" and what are the solutions/workarounds?

like image 484
Tom Robinson Avatar asked Sep 17 '08 13:09

Tom Robinson


1 Answers

You get this error when you call a function that was created in a window or frame that no longer exists.

If you don't know in advance if the window still exists, you can do a try/catch to detect it:

try {   f(); } catch(e) {   if (e.number == -2146823277)     // f is no longer available     ... } 
like image 97
Sjoerd Visscher Avatar answered Sep 19 '22 16:09

Sjoerd Visscher