Is there a way to kill the unload function with javascript(jquery)?
I am looking for something like this:
window.onbeforeunload = function(){
confirm("Close?")
}
or in jquery:
$(window).unload(function() {
confirm("close?")
});
Now, on window unload I get my confirm alert but it will continue in any case. Clicking cancel it won't stay on my page.
the function has to return false to abort or true to continue, so you cauld simply return the confirm like this:
window.onbeforeunload = function(){
return confirm("Close?")
}
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