In my program, if a user tries to leave a page, he'll receive a dialog box asking if he is sure he wants to leave.
How should I implement the 'cancel' option if the user chooses not to leave the page?
Source javascript code:
$(window).unload(function(){
var c= confirm ("Are you sure?");
if (c){
alert("Thanks. Good luck!");
}
else{
????
}
});
window.onbeforeunload = function() {
return 'You have unsaved changes!';
}
many question about this in stackoverflow How can I override the OnBeforeUnload dialog and replace it with my own?
JavaScript + onbeforeunload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With