...

View Full Version : Capturing browser close



gjc
01-02-2004, 04:27 PM
Anyone know how to capture the event fired when the user closes the browser using the "X" button?

I have a web application running in C# that locks objects in a Db but needs to unlock these objects if a user exits the browser.

Vladdy
01-02-2004, 05:39 PM
better off put a timer on the locked objects. You can never predict the manner in which the user exits your application for example, what if their computer crashes or there is power outage...

Robb
01-03-2004, 01:15 PM
I recently learned of 'onbeforeunload' in this forum. Used the the body tag detects even the X method of closing.

<body onbeforeunload="callfunction()"> will call your function before the user exits.

ROBB

beetle
01-03-2004, 02:01 PM
This subject has been beaten to death in many threads like this one on many forums like this one. Let me summarize for you:

There is no way to determine the difference between the browser closing and another action that triggers the unloading events. You cannot single-out browser closures from other types of unloading.

In short, what you ask, cannot be done.

BTW, onbeforeunload is IE-only -- even then -- it still fires at every page unloading and not just browser closures.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum