Last Comment Bug 124751 - Conditional Comments on Mozilla?
: Conditional Comments on Mozilla?
Status: VERIFIED WONTFIX
WONTFIX?
:
Product: Core
Classification: Components
Component: HTML: Parser (show other bugs)
: Trunk
: x86 Other
: P5 enhancement (vote)
: ---
Assigned To: harishd
: Moied
Mentors:
: 217581 380198 398016 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-02-10 13:09 PST by maks
Modified: 2007-09-29 14:08 PDT (History)
7 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description maks 2002-02-10 13:09:37 PST
ie has some usefull toll, which works with their broser upward to 5.0
they called this "Conditional Comments":
http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp

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
<!--&{document.layers!=null};
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
maks
Comment 1 Sivakiran Tummala 2002-02-10 13:27:10 PST
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.
Comment 2 Christopher Aillon (sabbatical, not receiving bugmail) 2002-02-10 13:36:07 PST
<!--&{document.layers!=null};
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:

<script language="JavaScript">
if (document.layers != null)
  document.write("You are using NS 4!")
</script>

The second way it is clear you are writing JavaScript code.  Your proposed way
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.
Comment 3 Sivakiran Tummala 2002-02-10 13:45:25 PST
Christopher, 
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 :) 
Comment 4 maks 2002-02-10 13:59:42 PST
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
browser even without javascript!
so the argument that it would not work on all browsers turns out to be an
argument in favour of this conditional comments.
Comment 5 Christopher Aillon (sabbatical, not receiving bugmail) 2002-02-10 14:18:31 PST
Stummalla, that is because of a midair collision gone bad.  I didn't touch those
fields but they got changed anyway.  Sorry.
Comment 6 Christopher Aillon (sabbatical, not receiving bugmail) 2002-02-10 14:22:32 PST
Maks, on the contrary.  If that works in IE _without_ JavaScript then I would
consider that a privacy invasion.  If I turn off JavaScript, I do not want any
pages to be able to access anything about my scripting environment.  I said no
JavaScript, and I don't want pages to be able to learn my navigator.appName or
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.
Comment 7 maks 2002-02-10 14:28:42 PST
Christopher, I didn't try it on IE without JavaScript, but the official
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."
Comment 8 Fabian Guisset 2002-02-10 14:43:07 PST
maks, (document.layers!=null) is a javascript statement. if such a conditional
comment doesn't require javascript to be enabled to be evaluated, then it's a
serious privacy issue, because you're effectively running potentially dangerous
javascript even when it is disabled.
Comment 9 maks 2002-02-10 14:55:51 PST
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>
<![endif]-->
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
actived JS.
Comment 10 Boris Zbarsky [:bz] (Out June 25-July 6) 2002-02-10 17:28:21 PST
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.

Comment 11 Christopher Hoess (gone) 2002-02-10 22:47:02 PST
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.
Comment 12 Johnny Stenback (:jst, jst@mozilla.com) 2002-02-11 00:43:28 PST
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.
Comment 13 harishd 2002-02-14 19:38:28 PST
I don't think it's worth the effort to fix this. WONTFIX.
Comment 14 Moied 2002-02-15 16:28:18 PST
verified WONTFIX
Comment 15 Ryan Gammon 2003-05-06 18:16:39 PDT
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?
Comment 16 Ryan Gammon 2003-05-27 17:53:04 PDT
I have a project at http://iestreamconv.mozdev.org that filters out ie-style
conditional comments before they hit the parser.
Comment 17 Richard Brodie 2003-08-28 04:01:24 PDT
*** Bug 217581 has been marked as a duplicate of this bug. ***
Comment 18 Ryan Flint [:rflint] (ping via IRC for reviews) 2007-05-09 13:11:35 PDT
*** Bug 380198 has been marked as a duplicate of this bug. ***
Comment 19 Phil Ringnalda (:philor) 2007-09-29 14:08:51 PDT
*** Bug 398016 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.