Windows Internet Explorer Web The Windows Internet Explorer 8 version vector refers to the build number that is stored in a registry key that is read when the browser starts. Developers can use version vectors to detect which version of the browser a viewer is using to view a website. Understanding browser detection best practices ensures that your website continues to function as expected when a client views it.
Windows Internet Explorer Web This document describes how to use version vector values. In addition, some sample code is provided to help developers implement and maintain the recommended browser detection methods.
-> Windows Internet Explorer HTML Windows Internet Explorer In addition to using the version vector when populating the Help About section, it also uses this value when processing conditional comments. Conditional comments are blocks of comments within the page's source code that can only be interpreted by. An annotation may contain one or more operators, characteristics, or values.
<!--[if gte IE8]>
Windows Internet Explorer Version 8 Windows Internet Explorer For example, the above code shows the commented code required to check and above. A greater than or equal comparison is used to ensure that the condition applies to future versions, so that when a new version is released, the code does not need to be updated.
The Windows Internet Explorer 5.5 5.5002 version vector also contains the browser minor version number. When testing browser major version numbers, the version vector is an integer. To check the browser minor version number, a decimal point and four digits are appended to the version vector. For example, the version vector for a release is .
<!--[if gte IE 5.5002]><p>You are using IE 5 or higher</p><![endif]–>
This code example shows what is needed to check the browser major version number and the browser minor version number. Required comment code. This allows you to further adjust the conditions appropriately.
– HTML [endif] downlevel-hidden downlevel-revealed Conditional comments contain hyphens ("") in both the opening and closing tags, similar to basic comments. The condition appears at the beginning of the tag and before the end of the tag. The content is placed in comment tags. These annotations are called typed annotations because any browser or browser version that does not support conditional annotations will ignore these annotations and the tags between them. Conditional comments without hyphens are called typed comments because low-level browsers will ignore these comments but will handle the tags between tags.
<![if lt IE 5.5]><p>
您正在使用早于
IE 5.5
的版本或另一个低级浏览器
</p><![endif]>
This code example shows checking the browser major version number and browsing Comment code required for the device version number. This allows you to further adjust the conditions appropriately.
Windows Internet Explorer (CSS) Windows Internet Explorer 8 Windows Internet Explorer 7 CSS using user agent string 1/Using conditional comments including using different cascading style sheet rules for specific versions. This allows you to ensure that clients do not receive fixes and changes to the target. You can also detect the browser version. The table lists the available characteristic values, operators, and or values that can be used to form conditional annotations.
Item | Example | Comment |
IE | [if IE] | IE The only characteristic value currently supported by Windows Internet Explorer is the string "" for representation. |
Value | [if IE 7] | Boolean true An integer or floating point number representing the browser version. If the version number matches the browser version, the value is returned. |
! | [if !IE] | NOT Boolean operator. Placing this operator directly before a characteristic value, operator, or subexpression indicates the opposite meaning of the expression. |
lt | [if lt IE 5.5] | true less than operator. Returns if the first parameter is less than the second parameter. |
lte | [if lte IE 6] | true less than or equal to operator. Returns if the first argument is less than or equal to the second argument. |
gt | [if gt IE 5] | true greater than operator. Returns if the first parameter is greater than the second parameter. |
gte | [if gte IE 8] | true greater than or equal to operator. Returns if the first argument is greater than or equal to the second argument. |
( ) | [if !(IE 7)] | Boolean subexpression operator. Use with operators to create more complex expressions. |
& | [if (gt IE 5)&(lt IE 7)] | AND true true operator. Returns if all subexpressions evaluate to . |
| | [if (IE 6)|(IE 7)] | OR true true operator. Returns if any subexpression evaluates to . |
true | [if true] | true always evaluates to true. |
false | [if false] | false always evaluates to false. |
HTML
<head>
<title>Test page</title>
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<!–[if gte IE 8]> <linkrel="stylesheet" type="text/css" href="/stylesheets/standards.css" /> <![endif]—>
<!–[if IE 7]> <linkrel="stylesheet" type="text/css" href="/stylesheets/ie.css" />
<![endif]—>
</head>
Windows Internet Explorer 7 Additionally, if you want to use the same style sheet for Windows Internet Explorer 7 and later, you can use the following sample code.
HTML
<head>
<title>Test page</title>
<!–[if gte IE 7]>
<linkrel="stylesheet" type="text/css" href="/stylesheets/ie.css" />
<![endif]–>
</head>
Windows Internet Explorer Windows Internet Explorer Note that the above code example uses a greater than or equal to comparison. This ensures that the code will work for future versions so that there is no need to update the code when a new version is released. Here are some other examples of various conditional statements.
<!--[if IE]><p>
您使用的是
Internet Explorer
。
</p><![endif]–>
<![if !IE]><p>
您没有使用高级
version of Internet Explorer
版本。
</p><![endif]>
<!--[if IE 8]><p>
欢迎使用
Internet Explorer 8
!
</p><![endif]–>
<!--[if !(IE 8)]><p>
您没有使用
Internet Explorer 8
。
</p><![endif]–>
<!--[if gte IE 7]><p>
您使用的是
IE 7
或更高版本。
</p><![endif]–>
<!--[if (IE 5)]><p>
您使用的是
IE 5
(任何版本)。
</p><![endif]–>
<!--[if (gte IE 5.5)&(lt IE 7)]><p>
您使用的是
IE 5.5
或
IE 6
。
</p><![endif]–>
<!--[if lt IE 5.5]><p>
请升级您的
version of Internet Explorer
版本。
</p><![endif]–>
<!--[if true]>
您使用的是
an <em>
高级
</em>
浏览器。
<![endif]–>
<!--[if false]>
您使用的是
a <em>
低级
</em>
浏览器。
<![endif]–>
<!--[if true]><![if IE 7]><p>
此嵌套注释在
IE 7
中显示。
</p><![endif]><![endif]–>