comparison 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
comparison
equal deleted inserted replaced
1035:f87d0fedc54c 1036:e214ac93d73e
1 // Detect browser quirks that we should be aware of.
2
3 function needsDynPrefix() {
4 var span = document.createElement("span");
5 span.innerHTML = "<script>alert('test');</script>";
6 var scripts = span.getElementsByTagName("script");
7 return scripts.length == 0;
8 }
9
10 var dynPrefix = needsDynPrefix() ? "<span style=\"display:none\">A</span>" : "";
11
1 // Function versions of operators 12 // Function versions of operators
2 13
3 function not(x) { return !x; } 14 function not(x) { return !x; }
4 function neg(x) { return -x; } 15 function neg(x) { return -x; }
5 16
303 for (var i = 0; i < len; ++i) 314 for (var i = 0; i < len; ++i)
304 scriptsCopy[i] = scripts[i]; 315 scriptsCopy[i] = scripts[i];
305 for (var i = 0; i < len; ++i) { 316 for (var i = 0; i < len; ++i) {
306 thisScript = scriptsCopy[i]; 317 thisScript = scriptsCopy[i];
307 try { 318 try {
308 eval(thisScript.textContent); 319 eval(thisScript.text);
309 } catch (v) { 320 } catch (v) {
310 doExn(v); 321 doExn(v);
311 } 322 }
312 if (thisScript.parentNode) 323 if (thisScript.parentNode)
313 thisScript.parentNode.removeChild(thisScript); 324 thisScript.parentNode.removeChild(thisScript);
354 if (child.parentNode) 365 if (child.parentNode)
355 child.parentNode.removeChild(child); 366 child.parentNode.removeChild(child);
356 } 367 }
357 368
358 var cls = {v : null}; 369 var cls = {v : null};
359 var html = flatten(cls, v); 370 var html = dynPrefix + flatten(cls, v);
360 x.closures = cls.v; 371 x.closures = cls.v;
361 372
362 if (pnode == "table") { 373 if (pnode == "table") {
363 var dummy = document.createElement("body"); 374 var dummy = document.createElement("body");
364 dummy.innerHTML = "<table>" + html + "</table>"; 375 dummy.innerHTML = "<table>" + html + "</table>";