title: How to prevent closing browser window?
body: <p>I tried the following code to get an alert upon closing a browser window:</p>
  
  <pre><code>window.onbeforeunload = confirmExit;
  function confirmExit() {
    return "You have attempted to leave this page.  If you have made any changes to the fields without clicking the Save button, your changes will be lost.  Are you sure you want to exit this page?";
  }
  </code></pre>
  
  <p>It works, but if the page contains one hyperlink, clicking on that hyperlink raises the same alert. I need to show the alert only when I close the browser window and not upon clicking hyperlinks.</p>