Skip to content

Instantly share code, notes, and snippets.

@y-temp4
Last active July 9, 2019 04:22
Show Gist options
  • Save y-temp4/58eb5930dbf83f5178bdd1a911cd074f to your computer and use it in GitHub Desktop.
Save y-temp4/58eb5930dbf83f5178bdd1a911cd074f to your computer and use it in GitHub Desktop.
window.onbeforeunload の変更を検知して「このサイトを離れますか?」のポップアップを表示しないようにする
Object.defineProperty(window, 'onbeforeunload', {
set(newValue) {
if (typeof newValue === 'function') window.onbeforeunload = null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment