Compatibility adjustment and control code for IE mode 360 compatibility mode

Source: Internet
Author: User

IE10/11 3 Alternative methods after conditional comments are not supported:

method One: Use the Ie=emulateie9 property to instruct the browser to use IE9 rendering technology

IE9 is supported for conditional comments.

<meta http-equiv= "x-ua-compatible" content= "IE=EMULATEIE9" >

Add the meta tag to the head of the HTML page so that IE10/11 can identify the conditional comment, and we can write the specific CSS code like IE6/7/8. But there is a downside to this, and it is clear that the browser will be able to IE9 the rendering mode instead of the latest IE10/11 technology.

method Two: Use the media query statement +-ms-high-contrast Property

The media query statement for CSS is a high-level CSS conditional statement that can determine whether a CSS can take effect based on some property and property values. Here, we want to use a IE10/11 unique property, it is-ms-high-contrast, only IE10/11 implemented this property, it can have two values of active or none, using the following media query statement:

@media All and (-ms-high-contrast:none), (-ms-high-contrast:active) {
/ * ie10+ CSS styles go here * /
}

Firefox, Google Browser does not recognize this property, so do not execute the query in the CSS, thus achieving the effect of conditional execution.

method Three: Use JavaScript to determine the type of browser

First use JavaScript to determine whether it is IE browser, if so, on the page's
var ms_ie = false;
var ua = window.navigator.userAgent;
var old_ie = ua.indexof (' MSIE ');
var new_ie = ua.indexof (' trident/');

if ((Old_ie >-1) | | (New_ie >-1)) {
Ms_ie = true;
}

if (Ms_ie) {
Document.documentElement.className + = "ie";
}

Compatibility adjustment and control code for IE mode 360 compatibility mode

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.