title: Making the leaving site confirm dialog not showing up when a button on the page is clicked
body: <p>I recently added a JavaScript dialog into my page, which will let the user confirm if they really want to leave the page. However, I also have buttons navigating to other pages on my page, and I don't want the leaving site confirm dialog to show up when users click these buttons.</p>
  
  <p>I haven't really found out a way on how to do this, partly because I'm new to HTML and JavaScript.</p>
  
  <p>Below is my code I'm using for the confirm dialog, which I also got from <a href="https://stackoverflow.com/questions/10311341/confirmation-before-closing-of-tab-browser">here</a> on Stack Overflow.</p>
  
  <pre><code>window.onbeforeunload = function (e) {
      e = e || window.event;
  
      if (e) {     // For IE and Firefox prior to version 4
          e.returnValue = 'Any string';
      }
  
      return 'Any string';     // For Safari
  };
  </code></pre>