Ok, I put together a test page and found out what I think is actually causing the problem I’m seeing.
Using Firefox 3.0.
In this case, using the jQuery library (1.2.6) and the wrapInner method of that library, it causes the page to go into a never-ending loop. When I hit stop and Inspect Element in Firebug, I get a blank, plain-jane DOM with only the inserted blah blah.
What I think is happening is that, when doc*ument.write happens, it attempts to put the text on the page, but does so in a way in which the wrapInner method then sees another DOM (created by doc*ument.write). From my searches on the error, the suggestion is the doc*ument.write does not work with XHTML doctypes.
That’s my guess, fwiw.
Here is the test code to reproduce (I saved it to my desktop and ran it from there). You’ll also want to do a find/replace on ‘*’ and save before running.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML Strict Mode - doc*ument.write test</title>
<scr*ipt type="text/java*script" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.js"></scr*ipt>
<scr*ipt type="text/java*script">
$(document).ready(function(){
$('div.block_page_body_parent').wrapInner('<div class="block"></div>');
});
</scr*ipt>
</head>
<body>
<div class="block_page_body_parent">
<h1>XHTML Strict Mode</h1>
<h3>doc*ument.write test</h3>
<p>This content should not be replaced.<br />
<scr*ipt type="text/java*script"><br />
//<![CDATA[<br />
var l=new Array();<br />
l[0]='>';l[1]='a';l[2]='/';l[3]='<';l[4]=' 117';l[5]=' 100';l[6]=' 101';l[7]=' 46';l[8]=' 116';l[9]=' 110';l[10]=' 117';l[11]=' 64';l[12]=' 97';l[13]=' 105';l[14]=' 112';l[15]=' 97';l[16]=' 116';l[17]=' 46';l[18]=' 115';l[19]=' 105';l[20]=' 117';l[21]=' 76';l[22]='>';l[23]='\"';l[24]=' 117';l[25]=' 100';l[26]=' 101';l[27]=' 46';l[28]=' 116';l[29]=' 110';l[30]=' 117';l[31]=' 64';l[32]=' 97';l[33]=' 105';l[34]=' 112';l[35]=' 97';l[36]=' 116';l[37]=' 46';l[38]=' 115';l[39]=' 105';l[40]=' 117';l[41]=' 76';l[42]=':';l[43]='o';l[44]='t';l[45]='l';l[46]='i';l[47]='a';l[48]='m';l[49]='\"';l[50]='=';l[51]='f';l[52]='e';l[53]='r';l[54]='h';l[55]='a ';l[56]='<';<br />
for (var i = l.length-1; i >= 0; i=i-1){ <br />
if (l[i].substring(0, 1) == ' ') doc*ument.write("&#"+unescape(l[i].substring(1))+";"); <br />
else doc*ument.write(unescape(l[i]));<br />
}<br />
//]]><br />
</scr*ipt><br />
</div><br />
</body><br />
</html>