我可以使用JavaScript或HTML打开IE 10兼容性视图吗? [英] Can I turn on IE 10 Compatibility View using JavaScript or HTML?

查看:80
本文介绍了我可以使用JavaScript或HTML打开IE 10兼容性视图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以Javascript或HTML编程方式打开IE 10兼容性视图?

How can I turn on IE 10 Compatibility View programmatically in Javascript or HTML?

我刚刚在< head> 标记中添加了以下元标记,但它无效。

I just added the following meta tag within the <head> tag, but it is not working.

<meta http-equiv="x-ua-compatible" content="IE=EmulateIE7" >

有没有办法在JS中做同样的事情?

Is there any way to do the same thing in JS?

推荐答案

我检查了msdn上的兼容模式文章 - 这里

I checked the compatibility mode article on msdn - here.

您的元标记仍然是在IE中启用兼容模式的方法10和IE 9。

Your meta tag is still the method for enabling compatibility mode in IE 10 and IE 9.

只要你有:

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
    <!-- Other meta tags etc. -->
<head>

然后它应该有效。您可以尝试使http-equiv值区分大小写(当前您将其设置为小写)。

Then it should work. You could try making the http-equiv value case sensitive (at the moment you've set it to lowercase).

另外,要回答关于JS的问题,您可以通过将浏览器引擎与IE的浏览器版本进行比较来检测浏览器是否处于兼容模式。但是,这涉及浏览器版本检测,这往往有点不可靠。此外,您无法在JS中设置用户的兼容模式。所以,至少目前,你必须坚持使用meta标签。

Also, to answer your question about JS, you can detect whether the browser is in compatibility mode by comparing the browser engine with the browser version for IE. However, this involves browser version detection, which tends to be a bit unreliable. Also, there isn't a way for you to set the user's compatibility mode in JS. So, for the moment at least, you'll have to stick with the meta tags.

我希望这会有所帮助。

允许您查看http标头信息的好插件是 IEhttpheaders 的。只需从该链接下载即可。安装。然后,当您启动IE时,转到工具菜单并选择DisplayIEhttpHeaders ...。当您访问您的站点时,它将列出标题响应。如果您修改答案以包含响应,那么我们可以查看是否存在问题。

A good plugin to allow you to view http header information is IEhttpheaders. Just download it from that link & install. Then, when you start IE, go to the tools menu and select 'DisplayIEhttpHeaders...'. When you visit your site it will list the header response. If you modify your answer to include the response, then we can see if it's the problem.

这篇关于我可以使用JavaScript或HTML打开IE 10兼容性视图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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