我维护的遗留Web应用程序具有很多旧的怪癖模式页面和很多新的标准模式页面。
在IE10中,如果我们的域名位于IE兼容性列表中,则我从IE中收到混合消息。
如果我将开发工具中的浏览器模式从IE10兼容视图更改为IE10,然后又返回到兼容视图,则会得到:
IE10开发人员工具有时会误显示浏览器模式吗?例如,当页面实际上由于doctype和X-UA-Compatible设置为IE = edge进入标准模式时,根据兼容性列表或其他条件猜测模式。
还是documentMode和userAgent不能可靠地测试我们所处的模式?
基本上,如果我们检测到用户处于该模式,则我们要告诉用户“嘿,您不再需要将我们的网站放在兼容性视图列表中”。
测试User-Agent字符串足以确定页面是否处于“兼容性视图”模式。如果UA字符串为MSIE 10.0, Trident/6.0
,则可以相信该页面处于IE 10标准模式。因此,在第一种情况下,我不相信开发人员工具报告的“浏览器模式:IE10兼容视图”,就像您观察到建议标准模式的页面外观所发现的那样。
对于您的情况,如果这是请求中的UA字符串,则意味着不遵守兼容性视图设置列表。浏览器模式和UA字符串是在发出请求之前生成的,因此它们不受X-UA-Compatible
标记或doctype
响应的影响。无论出于何种原因,似乎IE10都不尊重您域的“兼容性视图设置”列表中的条目。这是MSDN中该过程的说明:
(来源:microsoft.com)
As far as I know, you can rely on the user agent string to determine when to inform your visitors that they can remove your site from their Compatibility View Settings list (or deselect the Compatibility View button). Specifically, if the string is MSIE 7.0, Trident/6.0
, the browser mode is Internet Explorer 7 and the browser, as indicated by Trident/6.0
, is IE10.
There is a really good blog post from MSDN (where the graphic above comes from) about IE9 that goes in detail through browser mode vs document mode and specifies the behaviour of the browser and UA strings in those different situations. Unfortunately, I have not found a similarly detailed post about IE10, but I’m guessing/hoping that the behaviour is similar.
最后说明:当您说Web应用程序有很多旧的古怪页面时,我担心文档模式(古怪)和浏览器模式(兼容性视图)之间的混淆。我猜这不是您的问题的一部分,但是因为这种区别过去使我感到震惊,所以我只想在这里提一下。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句