View Full Version : Capturing browser close
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.
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...
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.
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.