onbeforeunload Event


/ Published in: JavaScript
Save to your folder(s)

This snippet uses the <code>onbeforeunload</code> event to ask users whether they want to remain on the current page or navigate to a new URL.


Copy this code and paste it in your HTML
  1. <script>
  2. window.onbeforeunload = function () {
  3. return "Type your text here";
  4. };
  5. </script>

Report this snippet


Comments


You need to login to view comments.