Created
January 24, 2013 18:32
-
-
Save gabamnml/4626160 to your computer and use it in GitHub Desktop.
Prevent close windows with confirm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onbeforeunload = function(e){ | |
if(confirm('Are you nuts? Do you really want to leave me?')){ | |
return 'OK, Good Bye then'; | |
} | |
else { | |
e = e || event; | |
if(e.preventDefault){e.preventDefault();} | |
e.returnValue = false; | |
return 'I said, "Are you nuts? Do you really want to leave me?"'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment