javascript beforeunload
window.addEventListener('beforeunload', (event) => {
// Cancel the event as stated by the standard.
event.preventDefault();
// Chrome requires returnValue to be set.
event.returnValue = '';
});
4.5
6
window.addEventListener("beforeunload", function(event) { ... });
window.onbeforeunload = function(event) { ... };
Thank you!
6
0
Are there any code examples left?
New code examples in category Javascript