onbeforeunload example
4 years ago in HTML
<!DOCTYPE html>
<html>
<body>
<script>
window.onbeforeunload = function() {
return "Leaving this page will reset the wizard";
};
</script>
<button onclick="window.close()">Close</button>
<button onclick="window.onbeforeunload = null">Disable onbeforeunload</button>
</body>
</html>