Re: xhtml+javascript. bug?

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 UTC