IE9开发人员工具中的IE9兼容性视图是什么? [英] What is IE9 compatibility view in IE9 Developer tools?

查看:108
本文介绍了IE9开发人员工具中的IE9兼容性视图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看IE 9开发人员工具,当我单击浏览器模式时,我会得到一个列表

I am looking at IE 9 developer tools and when I click on browser mode I get a list

IE 7
IE 8
IE 9
IE 9 Compatibility View 

那是做什么的? IE 9和IE 9兼容性视图有什么区别?

What does that do? What is the difference between IE 9 and IE 9 Compatibility View ?

推荐答案

主要的区别在于用户代理字符串.对于Internet Explorer 9,新的和改进的 UA字符串已发送:

The main difference is the User-Agent string. For Internet Explorer 9, the new and improved UA string is sent:

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

对于兼容性视图,将发送类似于以下字符串的内容:

For compatibility view, something similar to the following string will be sent:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; Zune 4.7)

请注意,兼容性视图UA字符串如何将浏览器标识为 MSIE 7.0 ?文档模式不足以使兼容性视图按预期工作.原因是如果您仍然告诉 Web服务器您正在运行IE 9,则您将无法真正实现向后兼容.它可能具有一些服务器端代码,这些代码可识别I​​E 7浏览器并提供特定于该浏览器的内容.因此,开发人员工具可让您有机会查看用户单击兼容性视图"图标时网页的外观,而无需永久打开兼容性视图.

Notice how the compatibility view UA string identifies the browser as MSIE 7.0? Document mode isn't enough for compatibility view to work as intended. The reason for this is you can't truly be backwards compatible if you still tell the web server you're running IE 9 — it may have some server side code that identifies IE 7 browsers and dishes out content specific to that browser. Thus, the developer tools gives you the opportunity to see how your web page would look if a user clicked the "Compatibility View" icon, without switching compatibility view on permanently.

为了完整起见,还值得一提的是,应用程序版本字符串以类似的方式更改. IE 9的应用程序版本字符串为:

For the sake of completeness, it's also worth mentioning that the app version string changes in a similar way. IE 9's app version string is:

5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

在兼容性视图中(可能因安装的软件而异):

And in compatibility view (may vary depending on software installed):

4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; Zune 4.7)

这些字符串与UA字符串非常相似,但是客户端脚本可能引用此字符串而不是UA字符串.不管兼容模式如何,仍可以在 Trident/5.0 部分的UA字符串和应用程序版本字符串中同时识别IE 9.

These strings are very similar to the UA string, but client-side scripts may refer to this string instead of the UA string. IE 9 can still be identified in both the UA string and the app version string from the Trident/5.0 part, regardless of compatibility mode.

这篇关于IE9开发人员工具中的IE9兼容性视图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆