473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Some new code I have not seen before

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
Nov 23 '05 #1
12 1523
Aaron Gray wrote:
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
Nov 23 '05 #2
VK

Aaron Gray wrote:
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/default.asp?url=/library/en-us/script56/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.

Nov 23 '05 #3

Aaron Gray wrote:
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.

Nov 23 '05 #4
Or
you never help anyone but you always has something to say to everyone!!
It's not nice.

Nov 23 '05 #5
cw******@yahoo.com wrote on 13 nov 2005 in comp.lang.javascript:
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>

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

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 23 '05 #6
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 23 '05 #7
"Or" <or*@ganpooh.com> wrote:
you never help anyone but you always has something to say to everyone!!
It's not nice.


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."

--
Ed Jay (remove M to respond by email)
Nov 23 '05 #8
Aaron Gray wrote:
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.
Nov 23 '05 #9

Richard Cornford wrote:
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.

Nov 23 '05 #10
cw******@yahoo.com said the following on 11/13/2005 5:32 PM:
Richard Cornford wrote:

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.


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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 23 '05 #11

cw******@yahoo.com wrote:
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/a...omment_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.

Nov 23 '05 #12
JRS: In article <6v********************************@4ax.com>, dated
Sun, 13 Nov 2005 10:39:12, seen in news:comp.lang.javascript, Ed Jay
<ed***@aes-intl.com> posted :
"Or" <or*@ganpooh.com> wrote:
you never help anyone but you always has something to say to everyone!!
It's not nice.


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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Nov 23 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Antoon Pardon | last post by:
I'm rather new at this, so I don't know how I should introduce this, nor whether these ideas are worth much but here goes. What I would like to change is access to variables on an intermediate...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
3
by: Zheng Da | last post by:
Program received signal SIGSEGV, Segmentation fault. 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 (gdb) bt #0 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 #1 0x40094c54 in malloc...
48
by: yezi | last post by:
Hi, all: I want to record some memory pointer returned from malloc, is possible the code like below? int memo_index; int i,j; char *tmp; for (i=0;i<10;i++){
19
by: felixnielsen | last post by:
Some might remember that i, not so long ago, started a treath or two about a weird 3d labyrinth. I now have a working code, that i want to share, hear comments, advice, ect., but first let me...
7
by: ramasubramanian.rahul | last post by:
hi i was trying to see how the compiler hides the static golbals from the linker and allows golbal varibale to be visable to the linker.i managed to figure out how it did that ( the .lcomm and...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
2
by: =?Utf-8?B?SkdASEc=?= | last post by:
I have a client that has contracted with a bank to process checks over the Internet. The solution includes a check scanner and APS.NET web application. The application does not work for all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.