Just some musing on my part. Couldn't you set a cookie on load and use that to stop the onunload function from happening on refresh. I have a page that sets a cookie so that when a user returns to a page an onload function doesn't fire, couldn't it work for onunload as well?
Well one way would be to use onkeypress (f5) I guess. of course that wouldn't work if the user used a menu. Interesting problem!! Sorry if I'm off base here but there must be a way.
This works in IE (haven't tested it anywhere else...)
var Leaving = true;
function leave() {
if ((window.screenTop > 10000) && (window.screenLeft > 10000)) {
/*...code here to open a window to perform cleanup on the host side - since this block is executed only when the browser is being closed */
}
else {
if(Leaving){
/* code here will be called for all other unload situations - you can add onclick='Leaving=false' to your own links that are not leaving your site */
alert('Now leaving ' + window.location.hostname);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.