title: message is shown twice before unload happens
body: <p>I want to give a message to user before page is unloaded . My page is in a  iframe and there are sidemenu int the page which on clicking load another iframe. I have written this code</p>
  
  <pre><code>window.onbeforeunload = function()
  {  
   return 'Any unsaved changes will be lost';
  }
  </code></pre>
  
  <p>the problem is that on clicking ok button this message is given again, and then again pressing ok it navigate to other page. How to avoid this</p>