Come over, where the action is - this site has moved!
Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!Willst du auch bei der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:

Browser gate for IE 5+ only

February 14th, 2005, 17:00

All of you probably came once to the conclusion: if your website should look really good, you need to install a browser gate to display different content to IE 5+, Mozilla and Opera. I came to this conclusion, too, when I was working on my brand new company website (Fabian Wolf-Webdesign).

So I searched the net for a ‘Browserweiche’, which translates as ‘browser gate’ (see title), and came up with following wonderful solution: Instead of writing a huge PHP- or Perl-based script, which uses Regular Expressions to find out which browser the current user is (ab)using, we can use so-called Conditional Comments, which only work in Internet Explorer 5 or later! ;)

So what’s all this fuzz about Conditional Comments?
Well, since version 5.0, the Internet Explorer supports so-called Conditional Comments (let’s call ‘em CCs from now on), which are interpreted ONLY by this browser, but not any other ones!
The syntax of CCs are very similar to normal comments, but act very similar like eXtended Server Side Includes (XSSI): you can define an If-Endif-Clause, including which browser version you’re referring to.

Example #1:

<!–[if IE ]>
<link rel=”stylesheet” type=”text/css” href=”inc/fww5_ie.css” />
<![endif]–>

Example #2, featuring a differentiation between IE 5.5 and IE 6:

<!–[if lte IE 5.5]>
Internet Explorer 5.5 or lower
<![endif]–>
<!–[if gte IE 6]>
Internet Explorer 6 or higher
<![endif]–>

Following are some comparison operators for the If-Endif-clause:

Operator Meaning
! not
lt lower than
lte less than or equal
gt greater than
gte greater than or equal
(nothing) equal

The original, german article in which I found the above mentioned information is available at: http://www.devmag.net/html/conditional_comments.htm

Note: thanks to some totally weired, fucked up bug the <!–more–&glt; function of WordPress doesnt seem to work properly together with the current apache install on this domain. Dont know why, thou.

Codework, Projects | Comments Jump to the top of this page

Comments are closed.