[Reprinted] HTML code that does not use the "Compatibility View" is mandatory, and the Compatibility View is

Source: Internet
Author: User

[Reprinted] HTML code that does not use the "Compatibility View" is mandatory, and the Compatibility View is

In Versions later than IE8, there is a "Compatibility View", making many new technologies unavailable. So how can I disable the browser from Automatically Selecting "Compatibility View" and force IE to display content in the highest available mode? The following section describes the HTML code.

X-UA-Compatible is an attribute used to set the compatibility mode of the IE browser. It was born after the IE 8 browser. IE8 or IE9 has many modes. For example, IE8 has four modes: IE5.5 weird mode, IE7 standard mode, IE8 standard mode, and IE8 standard mode. IE9 has seven modes: IE5.5 weird mode, IE7 standard mode, IE8 standard mode, IE8 standard mode, IE9 standard mode, IE9 standard mode, XML mode.

On pages that want to enable the standard rendering mode, we often use the code:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

To enable standard rendering mode of IE8. This method is suitable when only the IE8 browser exists, but later, IE9, IE10, and IE11 appeared. We can write as follows:

<meta http-equiv="X-UA-Compatible" content="IE=9;IE=8;IE=7;" />

That is to say, IE9 is the top priority. IE8 is used without IE9. If you write it for each type, it seems redundant. So we use the code to change the method:

<meta http-equiv="X-UA-Compatible" content="edge" />

Edge mode notifies IE to display content in the highest available mode, which breaks the "Lock" mode.

Of course, we have also seen such code:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

The chrome = 1 value is added to trigger Google Chrome Frame, but now Google has abandoned Google Chrome Frame, so you don't need to write it like this.

Summary:

1) on the <Meta http-equiv = "X-UA-Compatible" content = "edge"/>Trigger the standard mode. This is the most effective method. In this way, the button for setting compatibility mode in IE disappears. You can press F12 to open "Developer Tools" to check the browser mode.

2) Of course, you can also set it in the server code C #/VB. NET. Take VB. NET as an example:

Public Shared Sub SetHeadCompatible(ByRef myPage As Page)        Dim li As Literal = New Literal()        li.Text = "<meta http-equiv='X-UA-Compatible' content='edge' />"        myPage.Header.Controls.AddAt(0, li)End Sub

3) The settings mentioned above are only in the specified page, and pages not set will not be effective. If you want all the pages to be effective, you cannot set them on every page. You can set them in web Config:

<System. webServer> <! -- Edge mode notifies IE to display content in the highest available mode --> 

Source

Author: icech

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

Related Article

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.