Html 在 ie10 中强制浏览器和文档模式为 ie9

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15838605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:14:22  来源:igfitidea点击:

Force Browser and Document Mode to ie9 in ie10

asp.nethtmlinternet-explorer-10

提问by LeythG

This code:

这段代码:

<meta http-equiv="X-UA-Compatible" content="IE=9" />

seems to only change document to ie9 and not browser. Any ideas other than hitting F12 and changing it manually?

似乎只将文档更改为 ie9 而不是浏览器。除了按 F12 并手动更改之外,还有其他想法吗?

回答by David Storey

A site can not set the Browser mode. The browser mode is chosen before the browser requests content from the site. This specifies how the browser is identified to the site, such as the UA string.

一个站点不能设置浏览器模式。在浏览器从站点请求内容之前选择浏览器模式。这指定了浏览器如何被站点识别,例如 UA 字符串。

As you mentioned, the Document mode can be set by the author by including a X-UA-Compatible meta element, or by the DOCTYPE used. This overrides the default set by the browser for that browser mode.

正如您提到的,文档模式可以由作者通过包含 X-UA-Compatible 元元素或使用的 DOCTYPE 来设置。这会覆盖浏览器为该浏览器模式设置的默认值。

Changing the Browser Mode is only useful for using IE to test how an earlier version of IE would handle the site. You can change it on your local machine (but not for the site as a whole) by changing it in the F12 tool.

更改浏览器模式仅对使用 IE 测试早期版本的 IE 如何处理站点有用。您可以通过在 F12 工具中更改它在本地计算机上(但不是整个站点)更改它。

The user (and thus developer) can change the Browser mode by clicking on the Compatibility View icon in the URL field. This will also be only for that machine, and not for all users.

用户(以及开发人员)可以通过单击 URL 字段中的兼容性视图图标来更改浏览器模式。这也仅适用于该机器,而不适用于所有用户。

The only way to change the Browser mode globally is to get the site added to MS' Compat View List. But you don't want that unless the site uses a ton of old MS vendor specific code, and will not be updated.

全局更改浏览器模式的唯一方法是将站点添加到 MS 的兼容视图列表中。但是您不希望这样,除非该站点使用大量旧的 MS 供应商特定代码,并且不会更新。

You can read more at http://blogs.msdn.com/b/ie/archive/2010/10/19/testing-sites-with-browser-mode-vs-doc-mode.aspx

您可以在http://blogs.msdn.com/b/ie/archive/2010/10/19/testing-sites-with-browser-mode-vs-doc-mode.aspx阅读更多信息

回答by JonBruce

Optionally, you can alter the Web.config file to accomplish this as well. (You'll have to restart the service after publishing to see the changes.)

或者,您也可以更改 Web.config 文件来完成此操作。(您必须在发布后重新启动服务才能看到更改。)

<system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-UA-Compatible" value="IE=Edge" />
      </customHeaders>
    </httpProtocol>
</system.webServer>

回答by user3406495

You can use the FEATURE_BROWSER_EMULATION feature of Internet explorer.

您可以使用 Internet Explorer 的 FEATURE_BROWSER_EMULATION 功能。

Start regedit.exe, go to

启动regedit.exe,进入

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

or

或者

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

create a DWORD iexplore.exe and set the value to 9999 (0x270F).

创建一个 DWORD iexplore.exe 并将值设置为 9999 (0x270F)。

回答by Marco Pais

see this.

看到这个

you can force highest mode by adding:

您可以通过添加强制最高模式:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />