I need your help. I\'m working with JavaScript and I\'m not able to configure how to work on window.onbeforeunload
.
here\'s my simple code:
<
You could try that:
$(document).on('mousedown', 'a[href]', offBeforeUnload)
.on('mouseleave', 'a[href]', function () {
$(window).on('beforeunload', windowBeforeUnload);
});
function offBeforeUnload(event) {
$(window).off('beforeunload');
}
function windowBeforeUnload() {
if (!confirm("some message here")) {
return "Are you sure?";
} else{
return false;
}
}
$(window).on('beforeunload', windowBeforeUnload);
DEMO