title: Trigger onbeforeunload if form is not submitted
body: <p>I've got a form which is being submitted via PHP with 3 submit actions:</p>
  
  <ul>
  <li>Save and Continue</li>
  <li>Save and Exit</li>
  <li>Exit without Saving</li>
  </ul>
  
  <p>I'd like to trigger an "OnBeforeUnload" alert to display if the user DOES NOT click on any of the form actions to advise them that they're leaving the page, and their changes may not be saved.</p>
  
  <p>I've tried the following code but it seems as though the unbeforeunload is being triggered before my click event. Any suggestions on how best to achieve this?</p>
  
  <pre><code>$buttonpressed = false;
  $j(".Actions input").click(function(){
      $buttonpressed = true;                                  
  });
  
  if(!$buttonpressed){
      window.onbeforeunload = function(){
          return "Your changes may not be saved.";
      }
  }
  </code></pre>