This blog mainly describes how to make static HTML code display different content based on different IE versions. The trick here is to use the HTML comment expression of IE.
The HTML comment format is <! -- Comment content -->, IE extends HTML comments to support conditional expressions:
<! -- [If expression]> HTML <! [Endif] --> when expression is True, HTML content is displayed.
Example:
Copy codeThe Code is as follows:
<! -- [If IE 5]>
<P> Welcome to Internet Explorer 5. </p>
<! [Endif] -->
<! -- [If IE 5]>
<P> Welcome to Internet Explorer 5. </p>
<! [Endif] -->
Similar to programming languages, the expressions here also support operators such as greater than (gt), less than (lt), and or not. The following are some examples.
[If IE] determine whether IE
[If IE 7] determining whether it is IE7
[If! IE] determine if it is not IE
[If lt IE 5.5] determines whether it is IE5.5 or earlier. (<)
[If lte IE 6] determining whether it is equal to IE6 or earlier (<=)
[If gt IE 5] determine whether IE5 or later is used (>)
[If gte IE 7] determine whether IE7 or later is used
[If! (IE 7)] determine if it is not IE7
[If (gt IE 5) & (lt IE 7)] judge whether it is greater than IE5 and less than IE7
[If (IE 6) | (IE 7)] determine whether IE6 or IE7 is used
Sample Code:
Copy codeThe Code is as follows:
<! -- [If IE]> <p> You are using Internet Explorer. </p> <! [Endif] -->
<! [If! IE]> <p> You are not using Internet Explorer. </p> <! [Endif]>
<! -- [If IE 7]> <p> Welcome to Internet Explorer 7! </P> <! [Endif] -->
<! -- [If! (IE 7)]> <p> You are not using version 7. </p> <! [Endif] -->
<! -- [If gte IE 7]> <p> You are using IE 7 or greater. </p> <! [Endif] -->
<! -- [If (IE 5)]> <p> You are using IE 5 (any version). </p> <! [Endif] -->
<! -- [If (gte IE 5.5) & (lt IE 7)]> <p> You are using IE 5.5 or IE 6. </p> <! [Endif] -->
<! -- [If lt Internet Explorer 5.5]> <p> Please upgrade your version of Internet Explorer. </p> <! [Endif] -->