Skip to content

Instantly share code, notes, and snippets.

@fabi6ferreira
Last active October 14, 2022 15:27
Show Gist options
  • Save fabi6ferreira/a416016f6ae0e1bc80f67f8c6305b651 to your computer and use it in GitHub Desktop.
Save fabi6ferreira/a416016f6ae0e1bc80f67f8c6305b651 to your computer and use it in GitHub Desktop.
window.addEventListener('beforeunload', (event) => {
// Cancel the event as stated by the standard.
event.preventDefault();
// Chrome requires returnValue to be set.
event.returnValue = '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment