[Reprint] Force the HTML code to not use Compatibility view

Source: Internet
Author: User

Later in the IE8 browser version, there is a "compatibility view" that makes it impossible for many new technologies to be used. So how do you prevent the browser from automatically selecting Compatibility View, forcing IE to display content in the highest-level available mode? An HTML code is described below.

X-ua-compatible is a property that sets the compatibility mode of IE browser, which is born after the IE8 browser. There are many modes of IE8 or IE9, for example, IE8 has 4 modes: IE5.5 weird mode, IE7 standard mode, IE8 almost standard mode, IE8 Standard mode, and IE9 has 7 modes: IE5.5 weird mode, IE7 standard mode, IE8 almost standard mode, IE8 standard mode, IE9 almost standard mode, IE9 standard mode, and XML Schema.

In a page that wants to turn on standard rendering mode, we often use code:

<http-equiv= "x-ua-compatible"  content= "ie=8"/>

To turn on the standard rendering mode for IE8. This approach is only appropriate when there are IE8 browsers, but then there are IE9, IE10, IE11 and so on. We can write it this way:

<http-equiv= "x-ua-compatible"  content= "ie=9;ie=8;ie=7;" />

It means the first priority of IE9, no IE9 with IE8. So if you write for each one, it seems to be a bit redundant. So we change the way we use code:

<http-equiv= "x-ua-compatible"  content= "Edge"/ >

The edge mode notifies IE to display content in the highest-level available mode, which in effect destroys the "lock" mode.

Of course, we've also seen code like this:

<http-equiv= "x-ua-compatible"  content= "ie=edge,chrome=1" >

is to increase the chrome=1 value to trigger Google Chrome frame, but now Google has abandoned Google Chrome frame, so don't write it.

Summarize:

1) on the target page <Meta http-equiv= " X-ua-compatible " content=" Edge " /> trigger Standard mode, this is the most effective method. After setting the button in IE to set compatibility mode disappears, you can press F12 to open developer tools to check the browser mode.

2) Of course you can also c#/vb the service-side code. NET, take vb.net as an example:

 Public Shared Sub Setheadcompatible (ByRef as Page)        DimasNew  Literal ( )        "<meta http-equiv= ' x-ua-compatible ' content= ' Edge '/>"         myPage.Header.Controls.AddAt (0, Li) End Sub

3) The above-mentioned settings are only in the specified page, the page without settings will not be effective. If you want all the pages to be effective, you can not go to each page to set it, this time in the Web Config set:

<system.webserver>    <!--edge mode notifies IE to display content in the highest-level available mode -      <Httpprotocol>        <customheaders>          <Clear/>          <Addname= "X-ua-compatible"value= "Ie=edge" />        </customheaders>      </Httpprotocol></system.webserver>

Original source

Icech

Links: http://www.weste.net/2013/8-9/93109.html

[Reprint] Force the HTML code to not use Compatibility view

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.