468,765 Members | 1,730 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

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 6612
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.