The javascript code that formats the ad is actually visible on the page
itself, just above the ad. This is in spite of it being commented out I
looked at the source which has something like this:
<script type="text/javascript">
<!--
...
//-->
</script>
The script is apparently executed (because the settings affect the
color of the ad), but it's nonetheless shown on the page. At least in
Firefox, IE hides it.
What bothers me most is that the page nonetheless validates as XHTML.
Can anyone see the mistake?
It is your CSS, you have a rule at line 284 in themes/garland/style.css
with selector #header-region * that sets
display: inline;
and Mozilla seems to apply that then although it does not seem to make
much sense to change such settings on script elements.
--
Martin Honnen
http://JavaScript.FAQTs.com/
>> <script type="text/javascript">
>> <!--
>> ...
>> //-->
>> </script>
- -
> It is your CSS, you have a rule at line 284 in
> themes/garland/style.css with selector #header-region * that sets
> display: inline;
> and Mozilla seems to apply that then although it does not seem to make
> much sense to change such settings on script elements.
Well spotted. 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.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Thanks very much for that. I never would have seen it (I didn't even
know wildcards were allowed in CSS...)
And thanks for the heads-up on comments in script tags; I'll make sure
to take that into account in the future. This code isn't mine, so I'll
have to take that up with the people who wrote the module... >_<
Interesting. Can you cite some browsers that ignore scripts inside the
<!-- --> comment tags in HTML?
AJ
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.
http://ermarian.net/html/javascript/commented.html
The first field should always be filled when clicking the button; the
second field will only be filled if the browser doesn't throw out
commented Javascript.
In my browser (Firefox 2.0.0.1), the second field doesn't change. To be
really sure, I removed the comments and both fields were filled, so it
was really that which made the difference.
For me:
Fills both fields in IE6.
Fills only the first field in Firefox 1.5.0.9, SeaMonkey 1.0.7, Opera
9.02.
--
-bts
-Motorcycles defy gravity; cars just suck
The page is served as text/html to IE so whatever happens there does not
reflect upon the handling of comment-like structures inside SCRIPT
elements in XHTML documents.
> Fills only the first field in Firefox 1.5.0.9, SeaMonkey 1.0.7,
> Opera 9.02.
Where the content-type header sent is application/xhtml+xml and so the
mark-up is being interpreted as XHTML.
Richard.
Thanks. Yes, I knew that. <g> Arancaytar seemed to be looking for
confirmation.