TreeNet Webmaster wrote:
jk******@cs.tut.fi wrote:
<snip>
>... . There's the additional problem that using
<!-- and --to "comment out" the code is simply
wrong in XHTML (and hasn't been useful in HTML either
_for years_). It may _actually_ comment out the code
so that the browser won't see it at all. Of course, the
markup still _validates_, since validation does not deal
with such issues.
Interesting. Can you cite some browsers that ignore scripts
inside the <!-- --comment tags in HTML?
Strictly, inside the context of a SCRIPT element in HTML, they are not
mark-up at all, as the SCRIPT element has CDATA content.
You appear to be reading more into what was said than what was actually
written. The possibility of the - <!-- ... --- construct resulting in
any contained script being ignored only exists in XHTML, and (with the
exception of the parenthesised section) the subject of the above is
XHTML.
As XHTML is a type of XML, and XML parsers are allowed to discard
comments in XML source, it is possible that a script wrapped in that way
may never emerge from the parser. And as in XHTML the contents of a
SCRIPT element are PCDATA the wrapped script may (should) still be
interpreted as a comment and so not be presented to the javascript
parser even if they do make it through the XML parser.
I cannot say that I have tried (having long since totally abandoned the
practice of wrapping script content in mark-up comment-like constructs),
but the odds are very good that existing browsers are already ignoring
such scripts when presented with them inside genuine XHTML documents (as
opposed to the more normal (error filled and) tag-soup HTML documents
given (more or less) the illusion of its being XHTML to its authors, but
not to the browser (because of the use of text/html content type
headers, which results in the browser trying to interpret whatever it
gets as HTML)). As genuine XHTML is very rarely used, and even more
rarely scripted (certainly in a commercial context, where IE (with its
absolute inability to interpret XHTML) has to be given significant
consideration), this phenomenon can be expected to pass unnoticed by
many, and be an irrelevance to most.
In HTML the - <!-- ... --- construct wrapped around SCRIPT element
contents are just redundant, and have been so for at least half a
decade. They were introduced as a way of avoiding browser's that did not
know what a SCRIPT element was from displaying script source text to the
user. Those would be browsers pre-dating Netscape 2, and so now so old
that they are well past being of any practical concern to anyone.
Richard.