Freed script

T

Thor W Hammer

Hello all,

Is it possible to find out if a script is freed? This is actual when having
a pointer to a function and should determine if it is freed so we don't call
it and get error..

TWH
 
V

VK

Thor said:
Is it possible to find out if a script is freed?

How do you determine the term "freed" for JavaScript? ;-)
Any function exists in the scope until you manually removed it (by
setting to null).
a pointer to a function and should determine if it is freed so we don't call
it and get error..

if (typeof ptrMyFunction == "undefined") {
// then there is no such function
}
 
T

Thor W Hammer

No, if I have a pointer to a function that exists inside a frame (iframe)
and the the frame is unloaded or navigated to another place, then function
is still in memory but it is freed so that we get the error message "Can't
execute code from a freed script". What I want to do is to determine if the
script is freed so that I don't call it.
 
V

VK

Thor said:
No, if I have a pointer to a function that exists inside a frame (iframe)
and the the frame is unloaded or navigated to another place, then function
is still in memory but it is freed so that we get the error message "Can't
execute code from a freed script". What I want to do is to determine if the
script is freed so that I don't call it.

Oh, orphan script problem... It's even more interesting than freed/not
freed and never was really explored. In some circumstances you even
able to execute a function left from the previous page - as long as it
doesn't address to the DOM of the previous page (imaginary objects).
The latter simply crash Internet Explorer for example.

Well, I guess you still have a reliable checkpoint:
parent.frames['otherFrame'].document.location
and match it against some variable.

Also standard JavaScript doesn't have package scope visibility but you
can emulate it:

function myFunction() {
arguments.callee.packageName = 'package 1';
// the rest of the function
}

and from your script later:
if ((typeof myFunction == 'object') &&
(myFunction.packageName == currentPackage)) {
// ...
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top