473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.
Jul 20 '05 #1
2 5631
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andoni | last post by:
Hi, I am only writing for IE 5.5+ so no need for compatibility at all ;-) I am trying to get my users to logoff which they finish on a particular page. This is no problem (or should be no...
6
by: kaeli | last post by:
Hey guys, This error occurs ONLY in Netscape 7.0. Not in 7.1. So, I think it's a bug. Buuuut... Has anyone had this problem or know of a fix? When attempting to have an onunload function...
3
by: Laurent | last post by:
I am trying to use the onunload event to know when the user closes a popup by receiving a request on the web server. I have a main page from where the user opens a popup. What I want is when the...
3
by: Andrew Poulos | last post by:
In a frameset I have this: window.onload = function() { frames.onunload = function() { alert('I'm going now'); } } when frames unloads I'm expecting the alert to be called but it never...
2
by: Rich | last post by:
Is there any way to get the same effect that the body tag onUnload creates. I need a script that will be placed in the body of the html that will open a new window when the parent is closed. The...
1
by: Tim Arview | last post by:
Hi, I'm trying to create an exit popup that doesn't require anything added to the body tag. In other words, I don't want to say <body onunload="foo">. I just want to have window.onunload="foo"...
0
acoder
by: acoder | last post by:
Problem onload and onunload events do not fire when going back, forward or refreshing the page Browser Opera Example Any code using onload or onunload, e.g. window.onload = init; where...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.