IE 8的开发者工具:浏览器模式:IE 7,IE 8,但什么是IE 8"兼容性视图"?

nop*_*ole 8 internet-explorer internet-explorer-8 internet-explorer-7 ie8-compatibility-mode

在IE 8中,我们可以展示开发人员工具.然后在顶部,有一个浏览器模式:

IE 7
IE 8
IE 8 Compatibility View
Run Code Online (Sandbox Code Playgroud)

因此,如果IE 7要强制页面显示为浏览器是IE 7,并且
IE 8要强制使用标准IE 8显示页面,
那么额外的内容是什么IE 8 "Compatibility View"?有什么用?如果我们已经拥有IE 7,为什么需要这种额外模式?该模式IE 7不能做什么模式?

Jak*_*les 6

区别在于用户代理字符串.

"IE7"完全模仿IE7的用户代理字符串,显示MSIE 7.0."IE8"完全使用IE8的本机用户代理字符串,显示MSIE 8.0以及Trident/4.0,这是IE8中使用的Trident布局引擎的版本.

IE8-Compatibility使用浏览器的本机用户代理字符串,但将"8.0"更改为"7.0".

因为Trident在IE7之前没有版本号,所以IE7字符串不显示"Trident/xx".因此,对于MSIE 7.0用户代理字符串,如果还存在"Trident/4.0",则您知道IE8在兼容性视图中运行; 如果"Trident/xx"不在那里,你知道它是IE7模式下的真正IE7或IE8(不兼容模式).

我希望我的解释足够清楚,下面是一些用户代理字符串的示例.

IE7:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; FDM; MS-RTC EA 2; Tablet PC 2.0; .NET4.0C; .NET4.0E)

IE8:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; FDM; MS-RTC EA 2; Tablet PC 2.0; .NET4.0C; .NET4.0E)

IE8兼容性:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; FDM; MS-RTC EA 2; Tablet PC 2.0; .NET4.0C; .NET4.0E)