- From: David Dorward <david@dorward.me.uk>
- Date: Wed, 18 Feb 2009 14:48:52 +0000
- To: Daniel Marschall <info@daniel-marschall.de>
- CC: www-validator@w3.org
Daniel Marschall wrote: > I made a Anti-Spam-Mechanism which outputs following html code: > > <script language="JavaScript" type="text/javascript"><!-- > document.write("<a > href=\"");document.write("m");document.write("a");document.write("i");document.write("l");document.write("t");document.write("o");document.write(":");document.write("i");document.write("n");document.write("f");document.write("o");document.write("@");document..write("e");document.write("x");document.write("a");document.write("m");document.write("p");document.write("l");document.write("e");document.write(".");document.write("c");document.write("o");document.write("m");document.write("\">");document.write("i");document.write("n");document.write("f");document.write("o");document.write("@");document.write("e");document.write("x");document.write("a");document.write("m");document.write("p");document.write("l");document.write("e");document.write(".");document.write("c");document.write("o");document.write("m");document.write("</a>");// > --></script> > > Note: This is a JavaScript, it should be ignored by the validator! No. It is some code that appears between <script> and </script>. It shouldn't be ignored by the validator, it should be processed as the content of the script element requires. > When checked as XHTML 1.0 Transitional: Valid! But pointless, since all the code is commented out: http://dorward.me.uk/www/comments-cdata/ > When checked an HTML 4.01 Transitional: NOT valid! > > It says, that the closed Tag </a> was not opened. But this </a> is > inside the <!-- and --> because of the JavaScript! So, it should not > be an error! <script> elements in HTML are marked as containing CDATA, so <!-- and --> are not comments. See http://dorward.me.uk/www/comments-cdata/ and the document the validator pointed you towards when it reported that error: """ If this error occurred in a script section of your document, you should probably read this FAQ entry <http://validator.w3.org/docs/help.html#faq-javascript>. """ http://validator.w3.org/docs/help.html#faq-javascript -- David Dorward
Received on Wednesday, 18 February 2009 14:49:32 UTC