Browser Closed event??

alexk

Active member
Joined
Jul 23, 2002
Messages
34
Location
Israel
How can i know when user close the browser.
Not refresh page, not submit or repost - Close Browser ONLY.
Thanks.
 
Last edited by a moderator:
Before I give you a snippet of JavaScript that is often associated with advertisement popups, I have to ask, why? Why would you want to detect such an event?
 
Response to your question.

My ASPX application provide interface that allow to users select any Item from table and change his properties. For example: Table contain office workers of my firm. User can select any worker from the list and change his properties. To prevent from another User select the same worker - Im keep this worker locked for current User by using "http session ID".
When User close the Internet Browser, I can NOT destruct session object and unlock a worker because it is NO *** event fired.
Sorry about my English.

[edit]Please watch your language [/edit]
 
Last edited by a moderator:
In VBScript, you can use this

Code:
<SCRIPT LANGUAGE=VBScript>
	Sub Window_onUnload
		msgbox "Unload"
	End Sub
</SCRIPT>

But you cannot control the browser to remain open.
 
Response to your note.

I try code from above Post.
The UnLoad event fired when I refresh or PostBack the page.
Its not meet my requirement. I need capture Browser closing event ONLY.
Thanks.
 
For your case, I suggest you use "Cookies" rather than "http session". And Cookies will destroy by itself when user close the browser (do not set expires date).

So you no need to worry about the browser close event.

Is it meet your requirement?
 
Session cookies destroy themselves when the browser is closed. There is no need to detect the browsers termination. Simply requery the cookie on each request to ensure that the user is in fact authenticated.
 
Back
Top