title: IE: Back and Refresh buttons behave differently on onbeforeunload event and url hashtag changes
body: <p>Steps:</p>
  
  <ol>
  <li><p>Open a website in ie11(e.g. www.baidu.com), in the console, type:</p>
  
  <pre><code>window.onbeforeunload = function(){return "aaa";}
  </code></pre></li>
  <li><p>press <strong>Refresh button</strong>, an alert pops up, choose stay on this page</p></li>
  <li><p>in the console, type:</p>
  
  <pre><code>top.location = location.href+"#?id=aaa"
  </code></pre>
  
  <p>now the url should be www.baidu.com/#?id=aaa</p></li>
  <li><p>press <strong>Back button</strong>, works fine, return to www.baidu.com</p></li>
  <li><p>press <strong>Back button</strong> again, an alert pops up, choose stay on this page.</p></li>
  <li><p>in the console, type:</p>
  
  <pre><code>top.location = location.href+"#?id=aaa"
  </code></pre>
  
  <p>now the url should be www.baidu.com/#?id=aaa</p></li>
  <li><p>press <strong>Back button</strong> </p>
  
  <p><strong>Expected</strong>: return to www.baidu.com, Chrome Opera Firefox all return to www.baidu.com</p>
  
  <p><strong>Actual Result</strong>: an alert pops up, if you choose leave this page, you will be redirecting to the page before www.baidu.com.</p></li>
  </ol>
  
  <p>How can I resolve this, I want to return to www.baidu.com like Chrome does.</p>
  
  <p>Please help.</p>
  
  <p>I've tried using history.pushState, it works fine in ie11, but ie9 doesn't have history.pushState.</p>