W3C home > Mailing lists > Public > www-validator@w3.org > October 2014

Re: Incorrect error reported in Javascript

From: David Dorward <david@dorward.me.uk>
Date: Wed, 29 Oct 2014 22:36:16 +0000
To: "Arjan den Boer" <arjan@archill.net>
Cc: www-validator@w3.org
Message-ID: <E2AB0B17-8333-4E09-BF67-FCCA95A16C64@dorward.me.uk>
On 26 Oct 2014, at 21:39, Arjan den Boer wrote:

> /Line 37, Column 209/: end tag for element "A" which is not open
>
> |...g id='tn"+j+"' class='"+cn+"' 
> src='thumbnail.php?sqz=90&img="+imgs[j]+"'></a*>*"}
>
> |
>
> This is in the HEAD section of the document and within <script 
> ...><!-- and --></script> tags.
> Why is the validator checking to-be-generated-HTML within a 
> javascript, even within comment <!--/--> tags?

They aren't comments. The content of a script element is defined as 
CDATA so markup doesn't have its usual meaning. The token `</` cannot 
appear inside an element defined that way.

Use <\/a> if you need to represent an HTML end tag in a JavaScript 
string.

(The comments are only treated as such by browsers that don't recognise 
script tags, it is a hack to stop the JavaScript being rendered as text 
in Netscape 1 era browsers. Those browsers aren't used any more so 
wrapping a script with comments is pointless)



-- 
David Dorward
http://dorward.co.uk/
Received on Wednesday, 29 October 2014 22:36:50 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:18:11 UTC