[Mapbender-commits] r7469 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 25 06:40:08 EST 2011


Author: armin11
Date: 2011-01-25 03:40:08 -0800 (Tue, 25 Jan 2011)
New Revision: 7469

Modified:
   trunk/mapbender/http/javascripts/mod_savewmc.js
Log:
Bugfixing for onunload/onbeforeunload events

Modified: trunk/mapbender/http/javascripts/mod_savewmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.js	2011-01-24 15:24:05 UTC (rev 7468)
+++ trunk/mapbender/http/javascripts/mod_savewmc.js	2011-01-25 11:40:08 UTC (rev 7469)
@@ -316,11 +316,30 @@
 		if (saveInSession === 1) {
 			options.$target.each(function () {
 	//			$(this).mapbender().events.afterMapRequest.register(function () {
-				$(window).bind("unload",function(){
-					that.save({
-						session : true
-					});
-				});
+				var supportsOnbeforeunload = false;
+				for (var prop in window) {
+    					if (prop === 'onbeforeunload') {
+    						supportsOnbeforeunload = true;
+    						break;
+    					}
+				}
+				//alert("Support of onBeforeUnload: "+supportsOnbeforeunload);
+				if (supportsOnbeforeunload) {
+					//$(window).unbind('unload');
+					$(window).bind('beforeunload', function(){ 
+						alert("Write WMC to session - onBeforeUnload!");
+						that.save({
+							session : true
+						});
+					}); 
+				} else {
+					$(window).bind('unload', function(){ 
+						alert("Write WMC to session - onUnload!");
+						that.save({
+							session : true
+						});
+					}); 
+				}
 			});
 		}
 



More information about the Mapbender_commits mailing list