title: How to prevent calling onbeforeunload when page refresh
body: <p>I want to prevent calling the function <code>confirmExit()</code> when the page is refreshed. Is it possible to do that? </p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
     $.post("test.php");
  }
  &lt;/script&gt;
  </code></pre>