Before reading:
Before reading the specific content of the article, I hope you can open IE8 first, open http://www.taobao.com , and then enter in the address bar:
javascript:alert(document.documentMode +navigator.userAgent);void(0)
I don’t know if you are surprised after seeing the results. Anyway, I find it very strange, because there is no compatibility tag in the page meta, and there is no X-UA-Compatible tag in the http header when fiddler checks it. Why on earth does the website run in IE7 mode? Where's next?
IE7 compatibility mode and compatibility view
Yesterday, when I was reading an article about iframe highly adaptive in Word of Mouth, I found that the demo it provided was different from my demo in IE8. The online result was obviously the same as in IETester7. I also checked it and there was no compatibility mark in the meta. , fiddler checks that there is no X-UA-Compatible mark in the http header, but why are the online results different from the local ones? This made me depressed. After looking at it again, I found that the online demo did not display the "Compatibility View" button in IE8. Thinking about it, this must be the reason.
Later I found an article Just The Facts: Recap of Compatibility View. Although it didn’t solve the problem, the content was good. I would like to share it and quote one of its passages:
Compatibility View and the X-UA-Compatible tag are not equivalent
Compatibility View is something you do on the client. It affects three things: the User Agent string, the Version Vector (used in evaluation of conditional comments), and what mode DOCTYPEs that trigger Standards map to – IE8 Standards or IE7 Standards. The X -UA-Compatible <META> tag / header is something you use in page content / server-side and, when present, completely overrides Compatibility View settings on the client. It affects two things: the Version Vector and what mode DOCTYPEs that trigger Standards map to. It can't affect the UA string as it's already too late to change that – the client's already made the GET request to the server (and it contains a UA string). What this means to developers is that if your site pivots on the User Agent string, adding just the X-UA-Compatible tag (to cause IE8 to display your site in IE7 Standards mode) won't make your website compatible – you'll also need to update your User Agent string detection logic as well.
This means that the compatibility view plays three roles:
The meta tag only plays two roles: 1. Version, 2. Document type
(It is said here that the meta tag does not affect the UserAgent. It should refer to the ua on the server side. Because the client request has been sent and contains ua, it will not be affected. However, the client's ua is still affected, and ie7 is displayed.)
correct:
(Maybe the previous test was wrong) The client's ua will not be affected, it will only affect document.documentMode
in addition:
<META> tag / header respectively refers to: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> and adding http headers on the server side, such as in the .net configuration file:
In addition, you can also add http headers to IIS or Apache:
problem solving
At this point, the problem at the beginning of the article is still not solved. Last night, I accidentally saw Qin Ge’s article about using doctype to activate browser mode . It mentioned that compatibility mode will also be enabled in Microsoft’s blacklist site list. Remember the article above One of the two comments is: res://iecompat.dll/iecompatdata.xml (IE8 only). Enter this address into IE8 and it will display: Compatibility View list. In this way, you can finally find the domain names of Koubei and Taobao in this list. , so I think this should be the answer to the question at the beginning of this article. You can also find a domain name in this list, open it, and enter the javascript at the beginning of the article in the address bar (ps: Microsoft has too many lists) , converting so many sites into IE7.
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>