title: Javascript: onBeforeUnload() behaviour in IE and Chrome
body: <p>I have this piece of code:</p>
  <pre>
  window.onbeforeunload = function(){
        doSomething();
        return "Are you sure you want to leave";
  }
  </pre>
  <p>In Firefox when user leaves the page, <code>doSomething()</code> gets executed first and then the alert pops up.
  where as in IE and Chrome the alert pops up first and then if the user decides to stay <code>doSomething()</code>
  gets executed.</p>
  <p>Is there a way to make IE and Chrome behave like Firefox. I want to execute <code>doSomething()</code> before showing the pop up.</p>