Possible Duplicate:
javascript detect browser close tab/close browser
I wrote a window closing function given below
window.onunload = function() {
confirmBox();
}
function confirmBox(){
var con = confirm("Do you want to delete session and cookies?");
if(con == true)
logout();
}
There are three times the function called.
1) when refresing the page,
2) when go to another link within that site and
3) when the browser or tab will closed.
I just want the 3rd one. That is I want to call the window.close function or want to show the confirm box only when the tab or browser will closed.
Can anyone suggest how to accomplish this?