Js leaves or refreshes the page to detect of and is compatible with FF IE Chrome

  • 2020-03-30 02:12:25
  • OfStack


<!DOCTYPE html>
<html>
<head>
<script>
  function closeIt()
  {
    return "Any string value here forces a dialog box to n" + 
         "appear before closing the window.";
  }
  window.onbeforeunload = closeIt;
</script>
</head>
<body>
  <a href="//www.jb51.net">Click here to navigate to 
      www.jb51.net</a>
</body>
</html>

FF,IE,Chrome compatible js leave or refresh page detection, the key part is to have a return

Related articles: