title: Preventing Page unload, failure. Ideas?
body: <p>I'm trying to mimic a feature found even here on this site. But it doesn't appear to work. I am attempting to do this with jQuery 1.4.4 so far what I have, after crawling through as many examples I could find here and on other forms I came up with.</p>
  
  <pre><code>$(window).bind('beforeunload', function()
  {
      if(show_unsaved_warning == true)
      {
          //e.preventDefault();
          var exitBeforeSave = confirm('You have unsaved changes');
          if(exitBeforeSave == false)
          {
              return false;
          }
      }
  });
  </code></pre>
  
  <p>Which works to the point of displaying the confirmation dialog, but whether you click ok or cancel, the page still loads/reloads. I need to prevent this similar to the way stack does, so if there is changes made on a form, I can prompt the user to save the changes in case they forgot, or just let them leave. Is there something I am missing in this equation or is it just not possible?</p>
  
  <p>Please note I realize this is a question asked a dozen times over here on stack and on dozens of forums elsewhere. If I could piece something together based on the things I found otherwise I would n't ask. Im coming here with a obvious repeat question cause I am currently stuck.</p>
  
  <p><em><strong>edit</em></strong> I changed the code a tiny bit to work with the confirmation dialog, however, the problem still pretty much remains, and on firefox I am actually causing an ok/cancel dialog which after ok/cancel is clicked, firefox creates another prompt to leave/stay on its own. How can I avoid that behavior as well?</p>