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

OnUnLoad

P: n/a
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.
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ivo
"Simon Wigzell" <si**********@shaw.ca> wrote in message
news:QS_cb.15414$O85.8622@pd7tw1no...
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.


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
Jul 20 '05 #2

P: n/a
VK
On load:
....
if (Explorer) {self.attachEvent('onunload',sayByeBye);}
else if (Netscape) {self.addEventListener('onunload',sayByeBye,true); }
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.detachEvent('onunload',sayByeBye);}
else if (Netscape) {self.removeEventListener('onunload',sayByeBye,tru e);}
else {/* just forget it again*/}
Now do your refresh...

Simon Wigzell <si**********@shaw.ca> wrote in message
news:QS_cb.15414$O85.8622@pd7tw1no...
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.

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.