title: Getting onbeforeunload confirmation alert twice, when refreshing the URL?
body: <p>I am using the <code>window.onbeforeunload</code> for user confirmation, when user leaving the page, but confirmation alert happens twice only in IE.</p>
  <p>My code is:</p>
  <pre><code>&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
      pageEncoding=&quot;UTF-8&quot;%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
  &lt;title&gt;User confirmation&lt;/title&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
      /* Used for confirmation , to closing the window */
      window.onbeforeunload = function() {
  
          return &quot;Are you sure want to LOGOUT the session ?&quot;;
      };
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;Folow the steps which I said in Stack overflow&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The scenario is ,</p>
  <p>Step 1 : Run my code and open it in IE .</p>
  <p>step 2 : After the application loads,close the browser window . You will get a confirmation alert.</p>
  <p>step 3 : Give the <strong>cancel</strong> in the confirmation alert.</p>
  <p>step 4 : Then refresh the URL by pressing the <strong>ENTER button</strong> in the address bar.</p>
  <p>step 5 : Give <strong>ok</strong> in the alert.</p>
  <p>step 6 : Now you will the confirmation alert once again.</p>
  <p>Can anyone tell me how to solve this problem?</p>