Incorrect error reported in Javascript

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Incorrect error reported in Javascript

Arjan den Boer
Dear W3C,

I used the HTML validator to verify the following page: http://spain.archill.net/verslag.php and I get the following error:

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?

Thanks and regards,

Arjan den Boer



Reply | Threaded
Open this post in threaded view
|

Re: Incorrect error reported in Javascript

David Dorward-3

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/