Some new code I have not seen before

A

Aaron Gray

Hi,

Here's some new code I have not seen before it is used in WikiPedia as well

<!--[if lt IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

<!--[if IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

Does it work ?
How portable is it ?
What about old browsers ?
And 101 other questions :)

Here's WikiPedias :-

<!--[if lt IE 5.5000]><style type="text/css">@import
"/skins-1.5/monobook/IE50Fixes.css";</style><![endif]-->
<!--[if IE 5.5000]><style type="text/css">@import
"/skins-1.5/monobook/IE55Fixes.css";</style><![endif]-->
<!--[if gte IE 6]><style type="text/css">@import
"/skins-1.5/monobook/IE60Fixes.css";</style><![endif]-->
<!--[if IE]><script type="text/javascript"
src="/skins-1.5/common/IEFixes.js"></script>

Aaron
 
T

Thomas 'PointedEars' Lahn

Aaron said:
Here's some new code I have not seen before it is used in WikiPedia as
well

<!--[if lt IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

<!--[if IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

Does it work ?
[...]

Yes, and it is completely off-topic here.


PointedEars
 
V

VK

Aaron said:
Hi,

Here's some new code I have not seen before it is used in WikiPedia as well

<!--[if lt IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

<!--[if IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

Does it work ?
How portable is it ?
What about old browsers ?
And 101 other questions :)

That's called "conditional comments" and they are introduced and
supported by Internet Explorer:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/ccomment_ovw.asp>

But it works just great for all browsers in the way it's made. Here's
the code from my test page template:

<!--[if gte IE 5]>
<p>
<var onclick="testIE()">Test IE</var>
</p>
<![endif]-->
<![if ! gte IE 5]>
<p>
<var onclick="testGK()">Test GK</var>
</p>
<![endif]>

If browser is Internet Explorer 4.x or higher it understands the
conditional comments and parses it properly. So if it's version is 5.0
or higher - [if gte IE 5] it displays
<var onclick="testIE()">Test IE</var>
otherwise it displays
<var onclick="testGK()">Test GK</var>

If it's another browser w/o conditional comments support (Firefox for
example) it simply skips the first block because it looks just like
regular <!-- ... --> HTML comment and it displays
<var onclick="testGK()">Test GK</var>
which is still exactly what we wanted.


A similar approach but for JavaScript code is implemented by Microsoft
in conditional compilation:
<http://msdn.microsoft.com/library/d...pt56/html/js56jsconconditionalcompilation.asp>

Here is for example a block from my object dispatcher: depending on
what browser and what platform the script is running on, different
constructors are called:

/**
* Dispatching object request and degrade if needed
*/
/*@cc_on
@if (@_mac)
this.error.code = 1;
this.error.message = 'ActiveX is not supported on this platform.';
@elif (@_win32 && (@_jscript_version < 5))
this.error.code = 2;
this.error.message = 'JScript engine version is too low.';
@elif (@_win32 && (@_jscript_version >= 5))
jsFileManager_IE.call(this,mode);
@else @*/
if (typeof(netscape) == 'object') {
jsFileManager_GK.call(this,mode);
}
else {
this.error.code = 3;
this.error.message = 'XPConnect is not supported on this
platform.';
}
/*@end @*/
}

The beauty is that this works as needed with or without conditional
compilation support.
 
C

cwdjrxyz

Aaron said:
Hi,

Here's some new code I have not seen before it is used in WikiPedia as well

<!--[if lt IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

<!--[if IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

Does it work ?
How portable is it ?
What about old browsers ?

These are Microsoft conditional comments. Notice that they appear just
as regular html comments to most browsers following the usual W3C
standards for comments. However, IE browsers(at least the more recent
ones) are designed to see within a comment such as quoted by you and do
what the code within the comment requires. Notice that a start
conditional comment has to be matched by an end conditional comment
when the code for IE only is finished. These conditional comments seem
to work fairly well. It is very difficult to detect IE browsers using
script, because other browsers sometimes spoof them. Thus the IE
conditional comment can be of some use when you have to do something
only on IE browsers. There are several of these conditional comments. I
have a table of them somewhere, but I can not seem to find it just now.
 
E

Evertjan.

Thus the IE
conditional comment can be of some use when you have to do something
only on IE browsers.

Is this IE only, btw:

================

<!-- This text will not appear<br>in the browser window. -->

However, it will in IE:
<br>

<script type="text/javascript">
t = document.getElementsByTagName('!')[0]
document.write(t.text.replace(/</,'&lt;'))
document.write('<br>... and here:<br>')
document.write(t.innerHTML.replace(/</,'&lt;'))
document.write('<br>... and here:<br>')
document.write(t.outerHTML.replace(/</,'&lt;'))
</script>

================
 
R

Randy Webb

Or said the following on 11/13/2005 12:53 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

That is not to be pedantic, but a helpful hint if you didn't already
know how :)
you never help anyone but you always has something to say to everyone!!
It's not nice.

Stick around, you get used to Thomas' pedantic bullshit after a while.
It doesn't change anything, you just learn to ignore it.
 
R

Richard Cornford

Aaron said:
Here's some new code I have not seen before it is used in
WikiPedia as well

<!--[if lt IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

<!--[if IE 6]>
<style type="text/css" media="screen">
...
</style>
<![endif]-->

Does it work ?

In the sense that it currently does what is expected then it does work.
How portable is it ?

All HTML browsers that do not have an attitude towards the construct see
the surrounding <!-- and --> as grounds for completely disregarding the
contents. Thus this construct is either acted upon or ignored
completely.

Currently IE is the only browser that has been identified as supporting
this construct (so all others could be expected to ignore it).
Unfortunately history has taught us that any browser feature that is
used to exclude other (minority) browsers from accessing web sites will
eventually be implemented/spoofed in at least some other browsers, and
this construct is starting to be used to exclude non-IE browsers from
web sites. My money would be on IceBrowser being the first to implement
this construct (and pretend to be IE 6 in the prcess).
What about old browsers ?

They should ignore the construct.

<snip>

Richard.
 
C

cwdjrxyz

Richard said:
Currently IE is the only browser that has been identified as supporting
this construct (so all others could be expected to ignore it).
Unfortunately history has taught us that any browser feature that is
used to exclude other (minority) browsers from accessing web sites will
eventually be implemented/spoofed in at least some other browsers, and
this construct is starting to be used to exclude non-IE browsers from
web sites. My money would be on IceBrowser being the first to implement
this construct (and pretend to be IE 6 in the prcess).

You are correct, but just to make everything clear for those for which
IE conditional comments are new, it should be pointed out that there
are several browsers that are just slight variations of IE6. Usually
such browsers support nearly all of what IE6 supports, including IE
conditional comments. Some IE6 near-clones include MSN9, Avant, MyIE2,
and the SBC/Yahoo DSL browser. The main way these browsers differ from
IE6 is that they may add a few extras such as Yahoo mail, MSN mail
links, etc on the home page. However, very rarely you will find a few
obscure differences in how these browsers support code.
 
R

Randy Webb

(e-mail address removed) said the following on 11/13/2005 5:32 PM:
Richard Cornford wrote:




You are correct, but just to make everything clear for those for which
IE conditional comments are new, it should be pointed out that there
are several browsers that are just slight variations of IE6.

They are not "slight variations", they are IE6 with addons.
However, very rarely you will find a few obscure differences in how
these browsers support code.

AOL is one of the IE addons that actually take away some functionality
that IE offers. It does not support the window.external set of
instructions. Meaning, that unlike IE, you can not automate the adding
of a favorites in AOL like you can in IE.
 
C

cwdjrxyz

There are several of these conditional comments. I
have a table of them somewhere, but I can not seem to find it just now.

See
http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp
for a fairly complete discussion of IE conditional comments,

Note that the special "download-revealed" conditional comment discussed
by Microsoft does not use standard html comment tags. Thus it will give
an error indication when validated at the W3C. I do not know if there
will be a problem with any current non-Microsoft browser if you use the
"download-revealed" conditional comment, so one should check on several
browsers if it is used.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Sun, 13 Nov 2005 10:39:12, seen in Ed Jay
I'm in his kill file, so I can safely refute your comment. ;-)

Your statement is false.

His contributions are both accurate and many. He's just a bit draconian in
his adherence to "the rules."

To what he calls the rules, please. His rules differ from agreed Usenet
convention. He serves as a useful reminder of 1870-71, 1914-18, and
1939-45.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top