Detect the browser closing event of Alt+F4 in asp.net
How to detect the browser closing event in asp.net before page unload. I need to call the javascript function to clear the cookie expire time. In body onunload method I'm able to call the function but its calling even if I refresh the page. So, Could anyone can help me out. 开发者_JAVA百科Thanks.
There is no sure shot method of identifying the alt+f4 method of browser as it is happening client side and onunload will be called every time the page will be refreshed, even if you click a link or do a refresh. Instead, you can use a timeout function in javascript, that will call a server side page every 2-5 minutes and you can check the state in your server side code. If the page is not called within the defined time frame, it means that the user has closed the session and you can call Session.Abandon()
there.
精彩评论