define an IFRAME function to fix a bug on IE6 and IE7 to avoid to open a new window
authorStephanie Marcu <stephanie.marcu@logilab.fr>
Wed, 18 Mar 2009 15:09:31 +0100
changeset 1117 20a21b3153b0
parent 1116 163e6a65d488
child 1118 8ad7737fc458
child 1125 1fbeb11a27a3
child 1155 61149b53d441
define an IFRAME function to fix a bug on IE6 and IE7 to avoid to open a new window
web/data/cubicweb.compat.js
--- a/web/data/cubicweb.compat.js	Tue Mar 17 19:28:11 2009 +0100
+++ b/web/data/cubicweb.compat.js	Wed Mar 18 15:09:31 2009 +0100
@@ -242,7 +242,36 @@
 UL = createDomFunction('ul');
 
 // cubicweb specific
-IFRAME = createDomFunction('iframe');
+//IFRAME = createDomFunction('iframe');
+function IFRAME(params){
+  if ('name' in params){
+    try {
+      var node = document.createElement('<iframe name="'+params['name']+'">');
+      }catch (ex) {
+	 var node = document.createElement('iframe');
+      }
+  }
+  else{
+    var node = document.createElement('iframe');
+  }
+  for (key in params) {
+    if (key != 'name'){
+      var value = params[key];
+      if (key.substring(0, 2) == 'on') {
+	// this is an event handler definition
+	if (typeof value == 'string') {
+	  // litteral definition
+	  value = new Function(value);
+	}
+	node[key] = value;
+      } else { // normal node attribute
+	node.setAttribute(key, params[key]);
+      }
+    }
+  }
+  return node;
+}
+
 
 // dummy ultra minimalist implementation on deferred for jQuery
 function Deferred() {