W3C home > Mailing lists > Public > www-validator@w3.org > January 2002

Re: xhtml+javascript. bug?

From: Patrick <psyaeger@hotmail.com>
Date: Mon, 28 Jan 2002 02:55:05 -0500 (EST)
To: <www-validator@w3.org>
Message-ID: <OE46Pz7byFogLErJALN0001e169@hotmail.com>
Scripting elements pose a problem for XHTML compatibility. The XML parser will parse the script as a XML document unless you enclose your script in a CDATA block. Therefore, a JavaScript element would now look like:

      <script type="text/javascript">
      <![CDATA[ alert("hello"); ]]>
      </script>

     
This causes a hassle for all the current browsers as they will not like the CDATA block. For now, the only solution is to call the JavaScript from an external file. For example:

      <script language="JavaScript" type="text/javascript" src="main.js"></script>  


ALSO, IT SEEMS language="JavaScript" can cause a problem when validating. Just leave that out but do include type="text/javascript". This at least is what worked for me.

PSY


Received on Monday, 28 January 2002 18:21:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:00 GMT