How I can capture event, close browser window, in jQuery or javascript ?
This question is related to
javascript
jquery
events
Men, use this:
if(myWindow.closed){
callback();
return;
}
http://docs.jquery.com/Events/unload#fn
jQuery:
$(window).unload( function () { alert("Bye now!"); } );
or javascript:
window.onunload = function(){alert("Bye now!");}
Events onunload or onbeforeunload you can't use directly - they do not differ between window close, page refresh, form submit, link click or url change.
The only working solution is How to capture the browser window close event?
Source: Stackoverflow.com