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"); ]]>

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.


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

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:17:32 UTC