Is there a way to execute javascript function if user click "not leave" in beforeunload alert?
I use JQuery and the following code:
$(window).on('beforeunload', function (e) {
if (formSubmitting || !isDirty()) {
return undefined;
}
var confirmationMessage = 'You have unsaved work.';
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
});
So how to check, if user stays on the page or leave it?