Created
December 30, 2008 07:36
-
-
Save johnboxall/41548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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