Downlevel-revealed Conditional Comments to detect Internet Explorer 6 or less and the other browsers

I’ve found a couple of MSDN pages where you can learn the best ways to detect IE6 or IE5 (the ones that are at the root of most of the problems in displaying the net the way you want) and target them while presenting different content for ALL the other browsers.  The trick is in using Downlevel-revealed Conditional Comments. Go on to understand what I’m talking about.

Detecting Internet Explorer More Effectively

and

About Conditional Comments (the one will all the rules)

are the pages on MSDN with all the information.

This is the problem I used them for.

I had to display 2 different solution (implememted in php) for diplaying links to online articles. One for IE6 or lower and one for IE7 and greater and all the other browsers.

I put the solutions in 2 different PHP files and I wrote :

<!--[if (lte IE 6)]>

<?php  the code php?>

<![endif]-->

in the file for IE6 and less

and :

<![if (!IE)|(gte IE 7)]>

<?php  the code php?>

<![endif]>

and included the 2 filese.

The trick here is using the Downlevel-hidden Conditional Comments for IE6 or lower Explorer browser and Downlevel-revealed Conditional Comments for the browsers that can’t read the Explorer conditional comments: so, browsers different from Explorer and for IE7 or greater (that can read both).

Hope it would be of some help to you :)

This entry was posted in php. Bookmark the permalink.

Comments are closed.