In my project I need to get the user confirmation alert , when the user want to close the window/tab using X button.
But the window.on(\'before
$(document).ready(function () {
$('#navigate').on('mouseenter', stopNavigate)
.on('mouseout', function () {
$(window).on('beforeunload', windowBeforeUnload);
});
});
function stopNavigate(event) {
$(window).off('beforeunload');
}
function windowBeforeUnload() {
return 'Are you sure you want to leave?';
}
$(window).on('beforeunload', windowBeforeUnload);
DEMO
Try this -
$("a").mousedown(function() {
$(window).unbind();
});