title: How do I block the window.on('beforeUnload') event for <a> tag?
body: <p>In my project I need to get the user confirmation alert , when the user want to close the window/tab using <strong>X button</strong>.</p>
  <p>But the <code>window.on('beforeUnload')</code> also works for <strong>hyper link</strong> . How can I block this <code>leave page</code> alert for <code>&lt;a&gt;</code> tag ?</p>
  <p>My <strong>JSP</strong> will have the</p>
  <pre><code>&lt;a href=&quot;next.jsp&quot; id=&quot;navigate&quot;&gt; click here &lt;/a&gt;
  </code></pre>
  <p>My <strong>Jquery</strong> will have ,</p>
  <pre><code>$(document).ready(function(){
      $('#navigate').on('click', function() {
      stopNavigate(event);
      });
      
  });
  
  function stopNavigate(event){   
      $(window).off('beforeunload', function(){
          
      });
  }
  
  
  $(window).on('beforeunload', function(){
      return 'Are you sure you want to leave?';
  });
  
  $(window).on('unload', function(){
      logout();
  
  
  });
  </code></pre>
  <p>I don't want the <code>leave message alert</code> when the user click any <code>links</code>. I need the <code>leave message alert</code> only for <strong>window close operation</strong>.</p>