Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor
OnUnload event hadler during browser refresh EReynolds msg:590148 2:49 pm on Feb 18, 2001 (gmt 0) Hello I have a client that wants a popup window to load when a user leaves a certain page.
*Yes, I know this is bad etiquette. That's
between him and his customers.*
I haven't used the onUnload handler before
and it seems to be invoked when I manually refresh the browser. I may be picky, but I don't like it.
Has anyone found a way to short-circuit
the handler if a user manually refreshes the page? Basically, I don't want it to happen.
Thank you very much
tedster msg:590149 9:21 pm on Feb 18, 2001 (gmt 0)
Hello EReynolds, and welcome to WebmasterWorld.
Your question sent me digging through reference books and doing some online research, but the situation looks unresolvable to me because of two things --
1) a refresh always triggers an onUnload event
One solution (that really isn't a solution at all) might be to first use the onUnload event to trigger a confirm box that asks if the visitor really intends to leave the page.
Of course, then you've popped up something anyway, but if you really want to save the pop-up information until a true page exit, at least this technique would do that.
Jabbotts msg:590150 10:51 am on Apr 11, 2001 (gmt 0)
I have a similar situation. The only difference is that I don't mind if the browser refresh triggers the OnUnload. I want to be informed of internal server errors, so I'd like to submit the contents of a form on my Error 500 page to Matt Wright's formmail script whenever the user leaves. It should be up to the user if he fills the form out (comments, etc.) Even if blank, however, I would at least be notified of a problem.
Now I've only gotten the procedure to work upon a browser refresh, but unfortunately not on a normal unload like the back button or a manually typed URL.