[Javascript] innerHTML in xhtml

Hassan Schroeder hassan at webtuitive.com
Wed Oct 13 10:07:40 CDT 2004


Peter-Paul Koch wrote:

> Conclusion: Mozilla 1.6 does support innerHTML even in an
> application/xhtml+xml document.
> http://www.quirksmode.org/dom/innerhtmltest.xhtml . Opera does, too,
> but Safari doesn't.

Your test page shows it reading the innerHTML property, but have
you tried writing it? Here's a simplified test page; FireFox 0.9.1
throws an exception using the innerHTML line...

--------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>writing innerHTML</title>
<script type="text/javascript">
function init()
{
   try
   {
     document.getElementById("bog").innerHTML = "ABC";
     /* alternately, comment out the above and try this --

        var ABC = document.createTextNode("ABC");
        document.getElementById("bog").appendChild(ABC);
      */
   }
   catch ( oops )
   {
     alert(oops);
   }
}
window.onload=init;
</script>	
</head>
<body>
	<div id="bog"></div>
</body>
</html>
--------------------------------------------------------------------

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list