Skip to content

Instantly share code, notes, and snippets.

@kanakiyajay
Created November 20, 2014 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanakiyajay/659b46aa49cd278ab8c9 to your computer and use it in GitHub Desktop.
Save kanakiyajay/659b46aa49cd278ab8c9 to your computer and use it in GitHub Desktop.
javascript snippet to alert user from not leaving
window.onbeforeunload = function (e) {
e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
e.returnValue = 'Sure?';
}
// For Safari
return 'Sure?';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment