title: Best practice for warning the user they will lose data
body: <p>I have a site which uses a lot of JavaScript (mainly jQuery) and I need a nice global way to let the user know that they will lose unsaved changes when they navigate away from a particular page.</p>
  
  <p>At the moment I have an onchange event placed on the inputs and wrap my main navigation in a function which will display the warning when clicked.</p>
  
  <p>This feels really clunky and doesn't scale well (navigation which is not part of the main navigation needs to be manually wrapped, which is far from ideal)</p>