W3C home > Mailing lists > Public > www-validator@w3.org > March 2003

Re: Validator trying to validate javascript as HTML

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Thu, 20 Mar 2003 04:13:01 +0100
To: "Torben V. Rudgaard" <torben@jubii.dk>
Cc: www-validator@w3.org
Message-ID: <3e7f3133.19327561@smtp.bjoern.hoehrmann.de>

* Torben V. Rudgaard wrote:
>The script on my page looks something like this:
> 
><script language="javascript" type="text/javascript"> 
>  function addOption(targetElement,value){
>    for(var a=0 ; a<targetElement.length ; a++){
>      if( targetElement[a].text == value) value = '-'
>    }
>    for(var a=targetElement.length;a!=0;a--){
>      if( targetElement[a-1].selected)targetElement.remove(a-1)
>    }
></script>
>
>Validator thinks that because I use a "<" then its a HTML element.

You are probably validating as XHTML. In XHTML you must escape <, & and
]]> in <script> in order to have them interpreted properly. Try using

  <script ...>
  // <![CDATA[
  ...
  // ]]>
  </script>
Received on Wednesday, 19 March 2003 22:12:04 GMT

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