检测IE8兼容模式 [英] Detect IE8 Compatibility Mode

查看:192
本文介绍了检测IE8兼容模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在IE7兼容模式下区分IE7浏览器和浏览器

我们没有时间用我们相当广泛的系统来全面测试IE8。我们也达到了不能禁止使用IE8的程度。我们的用户很顽固,而且不是非常复杂,所以我们不认为我们可以告诉他们使用兼容模式按钮。相反,我们将IE = EmulateIE7元标记添加为临时修复。

We have not had time to fully test IE8 with our fairly extensive system. We are also reaching the point at which we can't prohibit the use of IE8. Our users are stubborn and not terribly sophisticated, so we don't feel that we can tell them to use the "Compatibility Mode" button. Instead, we will add the "IE=EmulateIE7" meta tag as a temporary fix.

问题是当使用此标记时,浏览器仍然报告自己是IE8,然后由我们的页面检测并拒绝。我可以理解为什么服务器端检测无法获取元标记(服务器在发送和处理元标记之前已经有用户代理),但客户端检查也会失败。如果在客户端计算机上单击兼容模式按钮,则用户代理是IE7,但如果我们使用元标记则不行。

The problem is that when this tag is used, the browser still reports itself to be IE8, which is then detected by our pages and rejected. I can understand why server-side detection can't pick up the meta tag (the server already has the user-agent before the meta tag is sent and processed), but client-side checks also fail. If the compatibility mode button is clicked on the client machines, the user-agent is IE7, but not if we use the meta tag.

这意味着,除其他事项外,我们必须禁用检查,然后,如果我们在某处犯了错误并忘记将元标记添加到页面,我们会破坏页面。

This means, among other things, that we have to disable the checking and then, if we make a mistake somewhere and forget to add the meta tag to a page, we will have broken pages.

有没有其他人遇到这个并提出更好的方法?当元标记设置模式时,是否无法检测IE8是否在兼容模式下运行?

Has anyone else encountered this and come up with a better approach? Is there no way to detect that IE8 is running in compatibility mode when the mode is set by the meta tag?

而且,我们知道有一个有效的学校我们认为我们应该让所有页面都与IE8标准模式兼容,但在我们现实的小角落里,现在这不是一个可行的选择(我会指出我们没有创建4或5个版本的IE必须以非标准方式编写。)

And, we do know that there is a valid school of thought that we should just make all the pages compatible with IE8 Standards mode but in our little corner of reality, that is not a feasible option right now (and I'll point out that we didn't create 4 or 5 versions of IE that had to be written for in a non-standard way).

推荐答案

IE8在User-Agent字符串中包含三叉戟令牌,无论如何兼容模式。

IE8 includes a trident token in the User-Agent string regardless of compatibility mode.

有关更多详细信息,请参阅MSDN: http://blogs.msdn.com/ie/archive/2009/01/09/the-internet- explorer-8-user-agent-string-updated-edition.aspx

See MSDN for more details: http://blogs.msdn.com/ie/archive/2009/01/09/the-internet-explorer-8-user-agent-string-updated-edition.aspx

Windows Vista上的IE7

Mozilla / 4.0(兼容) ; MSIE 7.0 ; Windows NT 6.0)

IE7 on Windows Vista
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)

Windows Vista上的IE8(兼容性视图)

Mozilla / 4.0(兼容; MSIE 7.0 ; Windows NT 6.0; Trident / 4.0

IE8 on Windows Vista (Compatibility View)
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0)

Windows Vista上的IE8

Mozilla / 4.0(兼容; MSIE 8.0 ; Windows NT 6.0; Trident / 4.0

IE8 on Windows Vista
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)

这篇关于检测IE8兼容模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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