Freed script

Discussion in 'Javascript' started by Thor W Hammer, Nov 21, 2005.

  1. 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
     
    Thor W Hammer, Nov 21, 2005
    #1
    1. Advertising

  2. Thor W Hammer

    VK Guest

    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
    }
     
    VK, Nov 21, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    >
    > 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
    > }
    >
     
    Thor W Hammer, Nov 21, 2005
    #3
  4. Thor W Hammer

    VK Guest

    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)) {
    // ...
    }
     
    VK, Nov 21, 2005
    #4
  5. :) Yep, I've already done that.


    "Jasen Betts" <> wrote in message
    news:...
    > On 2005-11-21, 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.

    >
    > $0.02 solution: use try/catch
    >
    > there may be a better way.
    >
    >
    >
    > --
    >
    > Bye.
    > Jasen
     
    Thor W Hammer, Nov 23, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dg
    Replies:
    0
    Views:
    329
  2. Martin Waller

    Can't execute code from freed script

    Martin Waller, Dec 3, 2004, in forum: ASP General
    Replies:
    1
    Views:
    253
    Martin Waller
    Dec 3, 2004
  3. Dirk Gently

    Can't execute code from a freed script

    Dirk Gently, Nov 12, 2004, in forum: Javascript
    Replies:
    4
    Views:
    406
    kaeli
    Nov 16, 2004
  4. reformy
    Replies:
    2
    Views:
    223
    LV_Indy
    Jun 30, 2005
  5. maya
    Replies:
    2
    Views:
    193
Loading...

Share This Page