Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.40 diff -u -r1.40 drupal.js --- misc/drupal.js 5 Oct 2007 09:35:08 -0000 1.40 +++ misc/drupal.js 20 Nov 2007 11:05:40 -0000 @@ -273,3 +273,17 @@ return '' + Drupal.checkPlain(str) + ''; } }; + +/* + * Called when there is unsaved data on the page + * Warn users leaving (or reloading) page that they would lose their changes + */ +Drupal.markPageUnsaved = function() { + // onbeforeunload works in FF, IE and Safari, but no in Opera (yet) + // it popups up a warning dialog with "OK" and "Cancel" buttons. + window.onbeforeunload = function() { return Drupal.t("You are leaving a page with unsaved changes that will be lost."); }; + // remove warning if user is clicking a submit or image button. + $(':submit,input:image').click( function() { + window.onbeforeunload = null; + }); +}; Index: modules/block/block.js =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.js,v retrieving revision 1.1 diff -u -r1.1 block.js --- modules/block/block.js 14 Nov 2007 09:49:30 -0000 1.1 +++ modules/block/block.js 20 Nov 2007 11:05:40 -0000 @@ -17,6 +17,7 @@ // A custom message for the blocks page specifically. Drupal.theme.tableDragChangedWarning = function () { + Drupal.markPageUnsaved(); //add warning popup to all links return '