OnUnLoad

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

    OnUnLoad

    I'm using OnUnLoad in my body statement to redirect to a function to clean
    things up if someone exits a form by closing it from outside the webpage
    code - e.g. by not using the cancel or save and exit buttons I have supplied
    but by clicking on the browser window top right X or closing it by clicking
    with the right mouse button on the tray icon for the window. Unfortunately
    it is also triggered by a refresh, which my web page does as part of it's
    functionality. Is there not a way of only trapping "improper" exiting of a
    web page? Thanks.


  • Ivo

    #2
    Re: OnUnLoad

    "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
    news:QS_cb.1541 4$O85.8622@pd7t w1no...[color=blue]
    > I'm using OnUnLoad in my body statement to redirect to a function to clean
    > things up if someone exits a form by closing it from outside the webpage
    > code - e.g. by not using the cancel or save and exit buttons I have[/color]
    supplied[color=blue]
    > but by clicking on the browser window top right X or closing it by[/color]
    clicking[color=blue]
    > with the right mouse button on the tray icon for the window. Unfortunately
    > it is also triggered by a refresh, which my web page does as part of it's
    > functionality. Is there not a way of only trapping "improper" exiting of a
    > web page? Thanks.[/color]

    Depends on why and when you refresh. Whether or not it is predictable enough
    to set a variable onbeforerefresh and don't set it otherwise. Then make the
    unload function check that variable before doing its thing.
    Ivo


    Comment

    • VK

      #3
      Re: OnUnLoad

      On load:
      ....
      if (Explorer) {self.attachEve nt('onunload',s ayByeBye);}
      else if (Netscape) {self.addEventL istener('onunlo ad',sayByeBye,t rue);}
      else {/* just forget it */}
      ....

      Then supposing you know when you want to refresh your site (and you should
      for sure!):

      Before refresh:
      if (Explorer) {self.detachEve nt('onunload',s ayByeBye);}
      else if (Netscape) {self.removeEve ntListener('onu nload',sayByeBy e,true);}
      else {/* just forget it again*/}
      Now do your refresh...



      Simon Wigzell <simonwigzell@s haw.ca> wrote in message
      news:QS_cb.1541 4$O85.8622@pd7t w1no...[color=blue]
      > I'm using OnUnLoad in my body statement to redirect to a function to clean
      > things up if someone exits a form by closing it from outside the webpage
      > code - e.g. by not using the cancel or save and exit buttons I have[/color]
      supplied[color=blue]
      > but by clicking on the browser window top right X or closing it by[/color]
      clicking[color=blue]
      > with the right mouse button on the tray icon for the window. Unfortunately
      > it is also triggered by a refresh, which my web page does as part of it's
      > functionality. Is there not a way of only trapping "improper" exiting of a
      > web page? Thanks.
      >
      >[/color]


      Comment

      Working...