diff lib/js/urweb.js @ 1036:e214ac93d73e

Deal with bizarre IE6 .innerHTML behavior (which eats some <script> tags)
author Adam Chlipala <adamc@hcoop.net>
date Sat, 21 Nov 2009 13:50:59 -0500
parents f87d0fedc54c
children 83d8ddd09d95
line wrap: on
line diff
--- a/lib/js/urweb.js	Sat Nov 21 13:08:01 2009 -0500
+++ b/lib/js/urweb.js	Sat Nov 21 13:50:59 2009 -0500
@@ -1,3 +1,14 @@
+// Detect browser quirks that we should be aware of.
+
+function needsDynPrefix() {
+  var span = document.createElement("span");
+  span.innerHTML = "<script>alert('test');</script>";
+  var scripts = span.getElementsByTagName("script");
+  return scripts.length == 0;
+}
+
+var dynPrefix = needsDynPrefix() ? "<span style=\"display:none\">A</span>" : "";
+
 // Function versions of operators
 
 function not(x) { return !x; }
@@ -305,7 +316,7 @@
     for (var i = 0; i < len; ++i) {
       thisScript = scriptsCopy[i];
       try {
-        eval(thisScript.textContent);
+        eval(thisScript.text);
       } catch (v) {
         doExn(v);
       }
@@ -356,7 +367,7 @@
     }
 
     var cls = {v : null};
-    var html = flatten(cls, v);
+    var html = dynPrefix + flatten(cls, v);
     x.closures = cls.v;
 
     if (pnode == "table") {