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?
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.
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.
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.
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.