It happens if you try to use an object which has member functions that are
defined in a script file which has since gone out of scope. I'll explain
the context I got it in.
I had two frames. One was the top frame, which persisted throughout the
lifetime of the app, one was the bottom frame which changed when the page
changed. The bottom frame contained basically the following script:
function testObject() {
this.memberString="memberString";
this.memberFunction=memberFunction;
}
function memberFunction() {
alert("Hi, I'm a member function of a testObject!");
}
myTestObject=new testObject();
myTestObject.memberFunction(); //this works
topFrame.savedTestObject=myTestObject;//save the object on the top frame for
a page switch
window.location.href="OtherBottomFramePage.htm";
then the other page had something like
myRestoredTestObject=topFrame.savedTestObject; //restore the object
myRestoredTestObject.memberFunction();
This gives the error you described, since memberFunction was only defined in
a block of script which has been destroyed along with the page it was on.
If you aren't doing something like this, you might be trying to call a block
of script on a page after it has been closed, for instance. If you have two
frames and one of them, on its unload event, calls script defined in the
other one, closing the browser may result in this error.
My solution was to copy the data instead of just trying to copy the object.
-Roy
-----Original Message-----
From: Scott Stanelle [mailto:scott_stanelle@h...]
Sent: Monday, March 10, 2003 6:24 PM
To: javascript
Subject: [javascript] Re: Can't execute code from a freed script
> Hello,
>
> I'm intermittently getting the above error message. Does anyone know how
> this can occur and any steps to rectify the problem?
> Thanks
Hi Andrew,
Just wondering whether you have a solution to this problem? I ran across
it for the first time today. It seems to only be a problem on IE?!?
Thanks.