Allow Web pages to display different content based on different IE versions _javascript tips

Source: Internet
Author: User
This blog is mainly about how to let static HTML code display different content according to different IE versions. The trick here is to use IE's HTML annotation expression.
The annotation format for HTML is <!--Comment content-->, IE extends HTML annotations so that they can support conditional judgment expressions:
<!--[if expression]> HTML <! [endif]--> Displays HTML content when the expression expression is true.
Example:
Copy Code code 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 greater-than (GT), less-than (LT), and or non-operator characters. Here are some examples.
[If IE] to determine whether IE
[If IE 7] to determine whether it is IE7
[If! IE] to determine if it is not ie
[If Lt IE 5.5] Determines whether the following version is IE5.5. (<)
[If LTE IE 6] is judged to be equal to IE6 version or below (<=)
[If GT IE 5] To determine whether IE5 above version (>)
[If GTE IE 7] determine if IE7 version or above
[If! (IE 7)] Judge whether it is not IE7
[If (GT IE 5) & (LT IE 7)] is judged to be greater than IE5, less than IE7
[If (IE 6) | (IE 7)] Judge whether IE6 or IE7
code example:
Copy Code code 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 IE 5.5]><p>please upgrade your version of Internet explorer.</p><![ Endif]-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.