[thelist] xmtml and internal javascript

Burhan burhankhalid at members.evolt.org
Sat Aug 17 21:30:01 CDT 2002

Hello Tom,

Saturday, August 17, 2002, 6:30:18 PM, you wrote:

TDA> Hey all,

TDA> I know that javascript must be external like css in XHTML files. I
TDA> came across this statement that said you can include internal JS in
TDA> XHTML if you enclose it in a character data (cdata) block like so:

TDA> <script language="JavaScript">
TDA> <!-- <![CDATA[
TDA> document.write("<h2>Table of Factorials</h2>");
TDA> for(i = 1, fact = 1; i < 10; i++, fact *= i) {
TDA> document.write(i + "! = " + fact);
TDA> document.write("<br />");
TDA> }
]]>> -->
TDA> </script>

TDA> Have any of you done this and does it validate?

TDA> Tom

Yes Tom, it works and validates. :)

Best regards,
 Burhan                            mailto:burhankhalid at members.evolt.org

More information about the thelist mailing list