I have a system where I need to know when the browser is closed in one file. This file is created and destroyed number of times in one session. I can get control in window.onbeforeunload event when the browser is closed as well as when the file is destroyed. I need to know when the browser is closed. I need to fire logout event on server when the browser is closed and not every time when the file is destroyed. I need to know this in the same file. How can I know in the same event weather the browser has been closed or the file has been destroyed and it has fired unload event. What I have tried is :
window.onbeforeunload = function(e) {
var e = e || window.event;
if (!(e.clientY > 0) || e.altKey) {
//Logout event
}
}
This causes logout every time the unload event is fired and not only when the browser is called.
Any help will be appreciated. Thanks in advance...