Skip to content

Instantly share code, notes, and snippets.

@Noitidart

Noitidart/.js Secret

Created June 18, 2017 01:17
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 Noitidart/e898a84a4f72e1b4c11ff7ca11a46bf7 to your computer and use it in GitHub Desktop.
Save Noitidart/e898a84a4f72e1b4c11ff7ca11a46bf7 to your computer and use it in GitHub Desktop.
var leaveCnt = 0;
window.addEventListener("beforeunload", function (event) {
leaveCnt++
if (leaveCnt === 1) return;
else event.returnValue = 'Are you sure?'
console.log('event:', event);
event.returnValue = 'asdf'; // JSON.stringify(event);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment