In the previous blog "Judging the current webpage display mode in IE8", I mentioned that IE has different display modes and how to use Javascript to dynamically determine. Web developers can import different content according to different display modes. 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 IE has made some extensions to HTML comments so that it can support conditional judgment expressions:
When expression is True, HTML content is displayed.
Example:
The Code is as follows:
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:
The Code is as follows:
You are not using Internet Explorer.