window.beforeunload code example
Example: javascript beforeunload
window.addEventListener("beforeunload", function(event) { ... });
window.onbeforeunload = function(event) { ... };
window.addEventListener("beforeunload", function(event) { ... });
window.onbeforeunload = function(event) { ... };