W3C home > Mailing lists > Public > www-validator@w3.org > April 2007

Re: Validator treats javascript as if it were HTML when <!-- //--> is missing.

From: Michael Adams <linux_mike@paradise.net.nz>
Date: Tue, 03 Apr 2007 08:13:10 +1200
To: www-validator@w3.org
Message-id: <20070403081310.69bf3292.linux_mike@paradise.net.nz>

On Mon, 02 Apr 2007 14:11:14 +0100
Mark Pawelek wrote:

> 
> The first error I get in my page is this:
> 
> 1. Warning Line 34 column 17: character "<" is the first character of
> a delimiter but occurred as data.
> 
>   for(var i=0; i < aMenu.length; i++)
> 
> I fixed the problem by using the <!--  //--> javascript fix but
> shouldn't the parser give me a more sensible error message?
> 

CDATA is treated differently in HTML and XHTML.
http://javascript.about.com/library/blxhtml.htm
Gives a plain english explanation and solution (of sorts).

You could also put those functions in another external .js file which
IMHO is the cleanest solution. You appear to be already familiar with
the technique of external javascript files judging by your supplied
code.

-- 
Michael
Linux: The OS people choose without $200,000,000 of persuasion.
Received on Monday, 2 April 2007 20:11:35 GMT

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