Last active
January 30, 2019 22:19
-
-
Save weizman/76832789d5fe0cb7aeac4238a7064508 to your computer and use it in GitHub Desktop.
cancelable `beforeunload` event example
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
// by https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload#Example | |
window.addEventListener("beforeunload", function (event) { | |
event.preventDefault(); // Cancel the event as stated by the standard. | |
event.returnValue = ''; // Chrome requires returnValue to be set. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment