ie has some usefull toll, which works with their broser upward to 5.0
they called this "Conditional Comments":
how could i have a workaround that only shows a portion of code in the newer
mozilla / netscape browser and not in ie
(this would be usefull for only showing to mozilla/netscape the sidebar feature)
a little bit like this one but not shown in netscape 4.x
You are using NS 4 or above!
thanks for your help, i found the ie conditional comments usefull perhaps you
could add their syntax to mozilla. what do you think?
with best regards
there are no conditional comments, but there is a workaround
navigator.userAgent can be used to check the browser and depending on the return
value you can write the code which applies to particular browser.
You are using NS 4 or above!
That's incorrect. Neither NS 6.x nor Mozilla support that document.layers.
In any case, how is that better than writing:
if (document.layers != null)
document.write("You are using NS 4!")
could be using VBScript, Tcl, who knows?
More importantly, the standard <script> works in ALL browsers which support
scripts. What you proposed only currently works in MSIE. Even if Mozilla does
support it, it is non-standard and there will be countless other browsers which
do not support it. Our support of this non-standard feature will encourage it's
use which will be bad for the web.
Comments are meant to be comments, not scripts. If you want to use a script,
then enclose it in script tags.
we are using the priority field for setting the importance of the bug. Please do
not change the priority field to null. If you disagree with the priority set by
anyone, feel free to change it :)
thanks for your usefull posts and comments.
i can understand your point of view focussing on standards,
but the force of the related function in the ie is that it works only on that
so the argument that it would not work on all browsers turns out to be an
argument in favour of this conditional comments.
Stummalla, that is because of a midair collision gone bad. I didn't touch those
fields but they got changed anyway. Sorry.
pages to be able to access anything about my scripting environment. I said no
document.layers or anything about my browser.
That "feature" defeats the whole purpose of being able to turn JS off. If you
want to access a JS property, you should be forced to use conventional <script>
methods and it's access restrictions, if any.
Microsoft tells us that you do not need any scripting. So "Conditional Comments"
should work even with deactived JS!
"It is not always necessary to use scripting and DHTML when working with
conditional comments, and when no scripting is used in a Web page, no scripting
engine needs to be loaded."
serious privacy issue, because you're effectively running potentially dangerous
Fabian, the following downlevel-hidden conditional comment shown on the
microsoft page (link above) checks for you ie browser version:
<!--[if IE 5]>
<p>Welcome to Internet Explorer 5.</p>
I don't know much about JS so I don't know if you meant that the statement above
(working with deactived JS) is equivalent to (document.layers!=null) with
If I might interrupt...
The HTML comment syntax is very well defined. The sequence of characters "<!"
does not mean "I get to make up what I do with it" but rather has a very
particular meaning in SGML and XML applications.
Looking at the examples listed on the page you reference:
<!--[if expression]> HTML <![endif]-->
Any browser that's claiming to be HTML-compliant should hide the content, unless
"HTML" contains the characters "--"
<![if expression]> HTML <![endif]>
In this case the [if expression] and [endif] should be interpreted as SGML
markup (possibly being ignored if they make no sense).
I fail how we can implement this feature (especially the "downlevel-hidden"
part) without completely breaking standards-compliant comment parsing. For
example, what does IE do with the following?
<!--[if IE 6]>
This is a test -- a test.
<![endif]--> Red ball.
If the words "Red ball" are visible in IE6 in CSS1Compat mode that's bad.
In the words of Arjun Ray when this came up on the W3C lists (February 2000), "Phony Baloney". The right way to do this sort of thing is a PI or markedsection, certainly not a comment. Given that this doesn't work in Opera, Lynx,&etc., will probably generate Issues with quirks comment parsing (as bz pointsout), and is generally a stupid abuse of markup, I suggest WONTFIX.The idea of delivering different parts of a single document to differentbrowsers/platforms using only markup is not entirely uninteresting, but as usual,MS failed to RTFM; I can't see that the mixed blessings of easier (but possiblymore wrong) browser-sniffing are worth the effort of implementing this kludge.Over to Parser, which is somewhat more apt as a component.
Um, I'm far from convinced that the world would be a better place if Mozilla
chose to support a syntax this messed up. I vote for WONTFIX.
I don't think it's worth the effort to fix this. WONTFIX.
One way to attack IE conditional comments without polluting the comment parsing
logic might be through feature request:
Bug 86504 (HTML Filter with Regular Expressions)
I also see some parser filtering stuff in htmlparser/public/nsIParserFilter.h --
is this being used by anything?
I have a project at http://iestreamconv.mozdev.org that filters out ie-style
conditional comments before they hit the parser.
*** Bug 217581 has been marked as a duplicate of this bug. ***
*** Bug 380198 has been marked as a duplicate of this bug. ***
*** Bug 398016 has been marked as a duplicate of this bug. ***