By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

Freed script

P: n/a
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
Nov 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
VK

Thor W Hammer wrote:
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
}

Nov 23 '05 #2

P: n/a
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.
"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Thor W Hammer wrote:
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
}

Nov 23 '05 #3

P: n/a
VK

Thor W Hammer wrote:
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)) {
// ...
}

Nov 23 '05 #4

P: n/a
On 2005-11-21, Thor W Hammer <th*********@hotmail.com> wrote:
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.


$0.02 solution: use try/catch

there may be a better way.

--

Bye.
Jasen
Nov 23 '05 #5

P: n/a
:-) Yep, I've already done that.
"Jasen Betts" <ja***@clunker.homenet> wrote in message
news:slrndo6tqh.lhb.ja***@clunker.homenet...
On 2005-11-21, Thor W Hammer <th*********@hotmail.com> wrote:
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.


$0.02 solution: use try/catch

there may be a better way.

--

Bye.
Jasen

Nov 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.