[Ie] browser mode and document mode and the processing method in development

Source: Internet
Author: User

Original article: http://blog.csdn.net/neo_liu0000/article/details/7589731

What are browser and text modes?

Those who often use the IE Developer Tools must have seen the browser mode and text mode. The two terms are described as follows:

Browser Mode(Browser mode), used to switch the default text mode of IE for the web page, parse conditional comments for different versions of browsers, and determine the value of useragent in the request header. It has been confirmed before the browser sends a request, and the Website Cannot modify this value. It represents the browser in which the user accesses the website.

 

Text mode(Document mode), in fact, is often referred to as the document mode. Different text modes correspond to different typographical engines and different JS engines. As mentioned above, each browser mode corresponds to a default text mode. The website can also change the text mode by some means, which indicates the mode in which the browser displays the page.

 

What is the use of browser mode and text mode?

It is used to solve compatibility issues caused by various ie versions. According to the Internet Explorer compatibility policy described by Microsoft, accessing a page in IE8 + requires the following process:

I,First, determine the browser mode. As mentioned above, the browser mode must be determined before the request is sent. By default, the latest mode (ie9 isIe9 Standard, IE8 isIE8 Standard), There are two ways to change it:

  • Select using the developer tool (see the table above for options );
  • Click the Compatibility View button;
  • Hit Compatibility View list (a list maintained by Microsoft that uses the Compatibility View. IE8 + by default, both the list and the lan url are used.CompatibilityMode );

II,The browser informs the server of the browser mode based on the useragent value in the request header;

III,The server can change the text mode of the browser in the following ways:

  • Doctype;
  • X-UA-compatible meta or corresponding Response Header

 

The browser mode determines: 1) the UA sent to the server; 2) the default text mode; 3) How to parse the condition annotation. It is determined before the request is sent and is not controlled by the server. Text mode determination: 1) typographical engine; 2) JS engine. After the browser gets a response, it determines that the server can control it through doctype or X-UA-compatible.

Test 1,According to the previous article, if the user's browser does not activate the Compatibility View, the IE developer tool is not enabled. The default browser mode of ie9 isIe9The default text mode isIe9 Standard(For IE8, It is similar), we change itIE7 Standard:

?
<meta http-equiv="X-UA-Compatible" content="IE=7">

Test 2,What if I add the test address to the compatibility list? According to the previous article, the browser mode should beIe9/IE8 compatibility, The corresponding text mode is stillIE7 Standard.

 

Test 3,If you change X-UA-compatible to IE = edge, continue to test in compatibility mode?

 

This conclusion is actually consistent with Test 1: X-UA-compatible is Ie = edge, which means that the text mode will use the latest available version. However, the text mode is changed, also, the browser mode is changed fromIe9/IE8 compatibilityChangeIe9/IE8. Ie9 sets the JS navigator. useragent according to the new browser mode. The UA of JS under IE8 remains unchanged.

Test 4,What if we use the developer tool to manually set the browser mode and text mode? After testing, the test is as expected. For example, in ie9, set the browser modeIE8, The text mode isIE7 StandardThe request header UA, js ua, and condition comments indicate that the browser mode isIE8, Both documentmode and JS engines indicate that the text mode isIE7 Standard. This is because the IE developer tool has the highest priority and all other conditions are ignored!

Conclusion

In IE8/9, X-UA-compatible changes the text mode, which means that the server can indirectly control the browser mode.

[Ie] browser mode and document mode and the processing method in development

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.