How to warn a user when he's leaving and there's unsaved data
JavaScript posted 9 months ago by christian
1 function confirmExit(enabled) { 2 window.onbeforeunload = (enabled) ? onUnloadMessage : null; 3 } 4 5 function onUnloadMessage() { 6 return "You're about to leave without saving!"; 7 } 8 9 // Enable 10 $('.input').change(function() { 11 confirmExit(true); 12 });