I have the following JavaScript
EDIT: included assignments for changesSaved
var changesSaved = true; $(document).ready(function ()
function bye(){ if(changesSaved) { return "You havent saved your changes." } }
This is how I do it.
or in pure JavaScript:
window.onbeforeunload = function() { if (changesSaved) { return "You haven't saved your changes."; } };