Does javascript have a stop() method like Java applets?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    #1

    Does javascript have a stop() method like Java applets?

    A Java applet has two methods stop() and destroy() that get called
    when the user moves to a different page. Does javascript have
    anything similar?

    thanks
    tom
  • kaeli

    #2
    Re: Does javascript have a stop() method like Java applets?

    In article <f00f4c38.04071 51023.1e882a0d@ posting.google. com>,
    tom.cowdery@big foot.com enlightened us with...[color=blue]
    > A Java applet has two methods stop() and destroy() that get called
    > when the user moves to a different page. Does javascript have
    > anything similar?[/color]

    When the user moves to a different page? No.
    You can catch the onUnload event, but it's not that good for anything.

    An applet needs a stop and destroy because it's always running and it
    needs to clean up after itself when it's no longer needed. Javascript is
    completely different.

    --
    --
    ~kaeli~
    If a chicken and a half can lay an egg and a half in a day
    and a half, how long would it take for a monkey with a
    wooden leg to kick the dill seeds out of a pickle?



    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Does javascript have a stop() method like Java applets?

      Tom wrote:[color=blue]
      > A Java applet has two methods stop() and destroy() that get called
      > when the user moves to a different page. Does javascript have
      > anything similar?[/color]

      From the Java 1.4.2 API documentation:

      | destroy()
      | Called by the browser or applet viewer to inform this applet
      | that it is being reclaimed and that it should destroy any
      | resources that it has allocated.
      |
      | [...]
      | stop()
      | Called by the browser or applet viewer to inform this applet
      | that it should stop its execution.

      Why do you require anything similar in client-side JavaScript?

      Almost all references are tied to the current document, that is, they
      do not longer exist if the document resource is changed. The script
      engine's garbage collector will automatically free memory allocated
      for objects and other data if there are no more references to them and
      the script engine stops execution as soon as the execution context that
      it is invoked for ends (but it preserves references to the allocated
      memory).


      PointedEars

      Comment

      Working...