Whether it's Google or Baidu's if IE condition annotation usage, the first few search results have errors and vulnerabilities, these vulnerabilities and errors caused me to mistakenly think that some ie condition comments have expired. Even if they are not invalid, I am puzzled. Today I took the time to read some stuff written by foreigners and tried it again. I was found to be puzzled because most of the articles were copied, but they were not tested in person, in the process of copying to copy, some key points are wrong: (the correct if IE condition annotation usage is summarized for future use:
Operator |
Example |
Description |
! |
[If! IE] |
Non-operator. This example indicates all non-ie browsers (Note: if it is to judge the non-IE browser with a version number, you need to add a subexpression, that is, Parentheses, such as: [If! (Ie 7)] indicates non-IE7) |
Lt |
[If lt IE 7] |
Smaller than the operator. If the first parameter is smaller than the second parameter, true is returned. In this example, the value is smaller than IE7 (not equal to IE7) |
LTE |
[If lte ie 7] |
Less than or equal to the operator. If the first parameter is less than or equal to the second parameter, true is returned. In this example, the value is less than or equal to IE7. |
GT |
[If gt ie 7] |
Greater than the operator. If the first parameter is greater than the second parameter, true is returned. In this example, the value is greater than IE7 (not equal to IE7) |
GTE |
[If gte ie 7] |
Greater than or equal to the operator. If the first parameter is greater than or equal to the second parameter, true is returned. In this example, the value is greater than or equal to IE7. |
() |
[If! (Ie 7)] |
Subexpression operator. This example indicates that the value is smaller than IE8 (excluding IE8) |
& |
[If (gt ie 6) & (lt ie 8)] |
And operator. If all the subexpressions are calculated as true, true is returned. In this example, the result is the same as that of [if IE 7 ]. |
| |
[If (ie 6) | (ie 7)] |
OR operator. If one of the calculation results of all subexpressions is true, true is returned. This example indicates that if it is IE6 or IE7 |
Common examples:
<! -- [If IE]> only recognized by IE <! [Endif] --> <! -- [If IE 6]> only IE6 can recognize <! [Endif] --> <! -- [If lt IE 7]> IE7 or lower (excluding IE7) identifiable <! [Endif] --> <! -- [If lte ie 7]> IE7 and IE can be identified <! [Endif] --> <! -- [If gte ie 7]> IE7 and IE can be identified <! [Endif] --> <! -- [If! IE]> <! --> Non-IE browser identifiable <! -- <! [Endif] --> <! -- [If! (Ie 7)]> <! --> Non-IE7 identifiable <! -- <! [Endif] -->
Note:
- 1. There is a space between "ie" and the version number, that is, "IE7" is incorrect;
- 2. The non-operator writing method is not the same as other methods. Please read it carefully.