2

I can't alert or can't do anything with this code. I want to run a function when f5 or exit page but firefox always return this messages: "This page is asking you to confirm that you want to leave - data you have entered may not be saved". How to fix this.

<!DOCTYPE html>
<html>
<body>

<p>Close this window, press F5 or click on the link below to invoke the onbeforeunload event.</p>

<a href="http://www.w3schools.com">Click here to go to w3schools.com</a>
      
<script>

  window.onbeforeunload = confirmExit;
  function confirmExit(){
    alert("confirm exit is being called");
    return false;
  }
</script>

</body>
</html>
ThinhLe
  • 409
  • 1
  • 3
  • 12

0 Answers0