Skip to content

Instantly share code, notes, and snippets.

@johnboxall
Created December 30, 2008 07:36
Show Gist options
  • Save johnboxall/41548 to your computer and use it in GitHub Desktop.
Save johnboxall/41548 to your computer and use it in GitHub Desktop.
var DIRTY = false;
// If an input has changed confirm navigation.
window.onbeforeunload = function() {
if (DIRTY) {
return 'You have unsaved changes.';
}
}
$(document).ready(function() {
// Watch all inputs for changes.
$(':input').change(function() {
DIRTY = true;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment