Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.     $(document).ready( function(){
  3.         var changes_to_be_saved = false;
  4.  
  5.         $('input,select,textarea').change(function(){ changes_to_be_saved = true });
  6.        
  7.         window.onbeforeunload = function() {
  8.             if ( !changes_to_be_saved && window['CKEDITOR'] ) {
  9.                 for ( var editor in CKEDITOR.instances ) {
  10.                     if ( CKEDITOR.instances[editor].checkDirty() ) changes_to_be_saved = true;
  11.                 }
  12.             }
  13.             if (needToConfirm) return "You have unsaved changes that will be lost if you leave...";
  14.         };
  15.     });
  16. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement