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

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 UTC