471,354 Members | 990 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

identifying between refresh and close browser actions

When we refresh the page (F5, or icon in browser), it will first
trigger ONUNLOAD event and then trigger
ONLOAD event. When we close the browser (X on right top icon), it will
trigger ONUNLOAD event.

Now when ONUNLOAD event is triggered, there is no way to distinguish
between
refresh the page or close the browser.

Here's the code fragment. The logic in window_unload() only applies to
closing the browser, not refreshing the page.

<BODY ONUNLOAD="window_unload()">
function window_unload()
{//logic that only applies to close the browser, not refresh the page.
}

Anyone knows the workaround to the problem?

Please advise. Thanks!!
Jul 23 '05 #1
1 7177
In article <ba**************************@posting.google.com >,
jr********@hotmail.com enlightened us with...

Now when ONUNLOAD event is triggered, there is no way to distinguish
between
refresh the page or close the browser.


If you need to care, your code is unsuitable for internet use. This group
assumes your code is for the internet unless otherwise specified.

I might also trigger onunload by moving to another url by typing it, by using
a bookmark, or by clicking a link. How would you handle those?
I might also just close a tab, yet keep my browser open (opera, netscape,
mozilla).

Code your application to be robust and stable and it won't matter if the user
refreshes or closes.

(by the by, I have yet to see a cross-browser "solution" to this problem)

--
--
~kaeli~
He had a photographic memory that was never developed.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Fred Nelson | last post: by
10 posts views Thread by Piotr Nowak | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.