title: Javascript OnPageUnload - on "leave page" must call additional method
body: <p>This is the problem: my web application (php) has a wizard feature which gathers customer's data page by page, and stores it in session. If customer tries to navigate away from the page before they have completed the wizard, I would like to display a massage to the effect of "You will lose your data". If the customer chooses to navigate away, the session data should be wiped.</p>
  
  <p>I know that I can intercept this action by binding <code>onpageunload</code> event, but is there a way to then make another call, e.g. <code>ajaxClearWizard()</code> if the customer says "yes"?</p>
  
  <p>PS I can see that, perhaps session shouldn't be used here, but I'm using an existing library, and although this wizard-data-persistence used to be a required feature the business now requires it to be removed :( </p>
  
  <p>Any ideas, alternatives? 
  Thanks in advance!</p>