<html>
<body onbeforeunload="return myFunction()">
<p>This example demonstrates how to assign an "onbeforeunload" event to a body element.</p>
<p>Close this window, press F5 or click on the link below to invoke the onbeforeunload event.</p>
<a href="../index.html">Click here to go to w3schools.com</a>
<script>
function myFunction() {
return "Write something clever here...";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload_html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:21 GMT -->
</html>