从代码强制IE文档模式 [英] Forcing IE Document Mode from code

查看:100
本文介绍了从代码强制IE文档模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要一种强制特定网站文档模式的方法。我没有任何办法让这些网站的开发人员放置适当的X-UA兼容标头。实际上我会想象我的代码作为IE 10或11扩展,拦截用户活动并根据列表强制文档模式。我知道Microsoft有自己的列表,称为 IE10 的兼容性视图列表[ ^ ],用于IE11 [ ^ ],由IE本身使用。但由于这些站点是Intranet站点,因此该列表没有用处。有可能在本地扩展该列表会很棒,但我没有找到任何方向。实际上HKEY_CURRENT_USER \Software \ Microsoft &\\Internet Explorer \BrowserEmulation键可以在某个地方引导,但似乎没有实际的文档可用,特别是对于UserFiler键。使用该策略也是一种选择,但你无法微调那里的设置。



最好的选择是使用与IE Developer Toolbar相同的方法强行文档模式更改 [ ^ ]。但是在获得 Internet Explorer Platform API 之后[ ^ ],我没有找不到任何可用于此的方法或属性:(



关键是,IE不仅以不同方式呈现页面,而且还在改变用户相应的代理字符串。在我的情况下,这是一个非常理想的功能,因为其中一些网站只接受某些特定的IE版本。



我希望有人能给我一些建议,关于如何在本地扩展iecompatviewlist.xml列表或如何重现IE Developer Toolbar功能。



提前谢谢你...



[更新]

我已经发现该列表有一个本地缓存:文件:\\%LOCALAPPDATA% \微软\ Internet Explorer \ I. ECompatData \ mycompatdata.xml ,但由于更新它直接更改它是没有意义的。

Hello all,

I need a method to force document mode for specific sites. I have no any means to make the developers of those sites to put proper X-UA-Compatible headers. Actually I would imagine my code as an IE 10 or 11 extension that intercepts user activity and forces document mode according to a list. I know that Microsoft has it's own list for that, called Compatibility View List for IE10[^], for IE11[^], used by IE itself. But as these sites are intranet sites, that list is of no use. It would be great to have a possibility to extend that list locally, but I haven't found anything in that direction. Actually the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation key could lead somewhere, but no actual documentation seems to be available especially for the UserFiler key. Using the policy is also an option, but you can't fine-tune the setting there.

The best option would be to use the same methods as IE Developer Toolbar is using when you force Document Mode change[^]. But after getting trough the Internet Explorer Platform APIs[^], I haven't found any method or property that could be used for this :(

The key point is, that IE not only renders the page differently, but it is changing user agent string accordingly. In my case this is a highly desirable feature, since some of those sites are accepting only some specific IE version.

I hope that somebody can give me some advice, either on how to extend the iecompatviewlist.xml list locally or how to reproduce the IE Developer Toolbar feature.

Thank you in advance...

[update]
I have figured out that there is a local cache for the list: File:\\%LOCALAPPDATA%\Microsoft\Internet Explorer\IECompatData\iecompatdata.xml, but as it is updated by the it makes little sense to change it directly.

推荐答案

这篇关于从代码强制IE文档模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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