Is it possible to detect if the browser is closing in JavaScript? I tried using:
$( window ).unload(function() {
//Code
});
and:
window.onbeforeunload = ExecuteMyCode;
function ExecuteMyCode() {
//Code
}
But this both executes when we also click a link, button,... I ONLY want to detect the browser close event.