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