Re: [VE][404] Error Message Feedback

Hello,

Matias wrote:
> Validating Error [404]: "character X is the first character of a
> delimiter but occurred as data"
> 
> Please, i donīt understand this error, Iīm using this javascript code:
> <script type="text/javascript">
>         var months=new Array(13);
>         months[1]="Enero";
>         months[2]="Febrero";
>         months[3]="Marzo";
>         months[4]="Abril";
>         months[5]="Mayo";
>         months[6]="Junio";
>         months[7]="Julio";
>         months[8]="Augosto";
>         months[9]="Septiembre";
>         months[10]="Octubre";
>         months[11]="Noviembre";
>         months[12]="Dciembre";
>         var time=new Date();
>         var lmonth=months[time.getMonth() + 1];
>         var date=time.getDate();
>         var year=time.getYear();
>         if (year < 2000)
>         year = year + 1900;
>         document.write(date + " de " + lmonth + " de " + year);
>         </script>
> The mistake appears in this line:  if (year < 2000)
> My personal web page is a valid xhtml 1.0 strict.

In XHTML the content of the SCRIPT element is PCDATA, so the parser (which
does not know anything about JavaScript) expects the '<' to start a start-
or end-tag.

Enclose the script content with '<![CDATA[' ... ']]>' to tell the parser
that you don't want characters like '<' to be parsed as markup delimiters.
Or move the script into an external file and reference it with 
<script src=".." type="text/javascript"></script>.

In HTML the SCRIPT element has CDATA content, so the parser would ignore any
markup delimiters (like '<', '&', ...) except for '</' followed by a
character (a..z, A..Z), which markes the end of the element content. So you
would not have this problem with HTML.


Hope that helps,

        Benjamin

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/

Received on Monday, 11 September 2006 08:43:40 UTC