includes/clientside/static/misc.js
changeset 440 105457df35e5
parent 339 5d62ef764b0d
child 458 c433348f3628
equal deleted inserted replaced
339:5d62ef764b0d 440:105457df35e5
   121 }
   121 }
   122 
   122 
   123 function disableUnload(message)
   123 function disableUnload(message)
   124 {
   124 {
   125   if(typeof message != 'string') message = 'You may want to save your changes first.';
   125   if(typeof message != 'string') message = 'You may want to save your changes first.';
   126   var body = document.getElementsByTagName('body');
   126   window._unloadmsg = message;
   127   body = body[0];
   127   window.onbeforeunload = function(e)
   128   body._unloadmsg = message;
   128   {
   129   body.onbeforeunload = function() { return this._unloadmsg };
   129     if ( !e )
       
   130       e = window.event;
       
   131     e.returnValue = window._unloadmsg;
       
   132   }
   130 }
   133 }
   131 
   134 
   132 function enableUnload()
   135 function enableUnload()
   133 {
   136 {
   134   var body = document.getElementsByTagName('body');
   137   window._unloadmsg = null;
   135   body = body[0];
   138   window.onbeforeunload = null;
   136   body.onbeforeunload = null;
       
   137   body._unloadmsg = null;
       
   138 }
   139 }
   139 
   140 
   140 /**
   141 /**
   141  * Gets the highest z-index of all divs in the document
   142  * Gets the highest z-index of all divs in the document
   142  * @return integer
   143  * @return integer