Html 强制 IE9 模拟 IE8。可能的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4811801/
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 06:22:50  来源:igfitidea点击:

Force IE9 to emulate IE8. Possible?

htmlinternet-explorerbrowserie8-compatibility-modex-ua-compatible

提问by adamJLev

Is this possible at all? I tried adding this to the page but it didn't change a thing.

这可能吗?我尝试将此添加到页面,但它没有改变任何事情。

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

UPDATE- I'm trying to do this because our site has some IE9 specific CSS issues, which wouldn't appear in IE8.

更新 - 我正在尝试这样做,因为我们的网站有一些 IE9 特定的 CSS 问题,这些问题不会出现在 IE8 中。

Thanks

谢谢

回答by jsims281

You can use the document compatibility mode to do this, which is what you were trying.. However, thing to note is: It must appear in the Web page's header (the HEAD section) before all other elements, except for the title element and other meta elements Hope that was the issue.. Also, The X-UA-compatible header is not case sensitive Refer: http://msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29.aspx#SetMode

您可以使用文档兼容模式来执行此操作,这正是您所尝试的。但是,需要注意的是:它必须出现在网页的标题(HEAD 部分)之前的所有其他元素中,除了标题元素和其他元元素希望是问题所在。另外,X-UA 兼容标头不区分大小写 参考:http: //msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29 .aspx#SetMode

Edit: in case something happens to kill the msdn link, here is the content:

编辑:万一发生什么事情杀死了 msdn 链接,这里是内容:

Specifying Document Compatibility Modes

You can use document modes to control the way Internet Explorer interprets and displays your webpage. To specify a specific document mode for your webpage, use the meta element to include an X-UA-Compatible header in your webpage, as shown in the following example.

<html>
<head>
  <!-- Enable IE9 Standards mode -->
  <meta http-equiv="X-UA-Compatible" content="IE=9" >
  <title>My webpage</title>
</head>
<body>
  <p>Content goes here.</p>
</body>
</html> 

If you view this webpage in Internet Explorer 9, it will be displayed in IE9 mode.

The following example specifies EmulateIE7 mode.

<html>
<head>
  <!-- Mimic Internet Explorer 7 -->
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
  <title>My webpage</title>
</head>
<body>
  <p>Content goes here.</p>
</body>
</html> 

In this example, the X-UA-Compatible header directs Internet Explorer to mimic the behavior of Internet Explorer 7 when determining how to display the webpage. This means that Internet Explorer will use the directive (or lack thereof) to choose the appropriate document type. Because this page does not contain a directive, the example would be displayed in IE5 (Quirks) mode.

指定文档兼容模式

您可以使用文档模式来控制 Internet Explorer 解释和显示您的网页的方式。要为您的网页指定特定的文档模式,请使用 meta 元素在您的网页中包含 X-UA-Compatible 标头,如以下示例所示。

<html>
<head>
  <!-- Enable IE9 Standards mode -->
  <meta http-equiv="X-UA-Compatible" content="IE=9" >
  <title>My webpage</title>
</head>
<body>
  <p>Content goes here.</p>
</body>
</html> 

如果您在 Internet Explorer 9 中查看此网页,它将以 IE9 模式显示。

以下示例指定 EmulateIE7 模式。

<html>
<head>
  <!-- Mimic Internet Explorer 7 -->
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
  <title>My webpage</title>
</head>
<body>
  <p>Content goes here.</p>
</body>
</html> 

在此示例中,X-UA-Compatible 标头指示 Internet Explorer 在确定如何显示网页时模仿 Internet Explorer 7 的行为。这意味着 Internet Explorer 将使用指令(或没有指令)来选择适当的文档类型。由于此页面不包含指令,因此该示例将在 IE5 (Quirks) 模式下显示。

回答by Nicholas Carey

Yes. Recent versions of IE (IE8 or above) let you adjust that. Here's how:

是的。最新版本的 IE(IE8 或更高版本)可让您进行调整。就是这样:

  • Fire up Internet Explorer.
  • Click the 'Tools' menu, then click 'Developer Tools'. Alternatively, just press F12.
  • 启动 Internet Explorer。
  • 单击“工具”菜单,然后单击“开发人员工具”。或者,只需按F12

That should open the Developer Tools window. That window has two menu items that are of interest:

这应该会打开开发者工具窗口。该窗口有两个有趣的菜单项:

  • Browser Mode.This setting determines the value of the user-agent header sent for every request.
  • Document Mode.This setting determines how the rendering engine renders the page.
  • 浏览器模式。此设置确定为每个请求发送的用户代理标头的值。
  • 文档模式。此设置确定渲染引擎如何渲染页面。

More at http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx

更多信息请访问http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx

回答by Ben

The 1st element as in no hard returns. A hard return I guess = an empty node/element in the DOM which becomes the 1st element disabling the doc compatability meta tag.

第一个元素没有硬回报。我猜是一个硬返回 = DOM 中的一个空节点/元素,它成为第一个禁用文档兼容性元标记的元素。

回答by Alexander

On the client side you can add and remove websitesto be displayed in Compatibility View from Compatibility View Settingswindow of IE:

在客户端,您可以从IE 的兼容性视图设置窗口添加和删​​除要在兼容性视图中显示的网站

Tools-> Compatibility View Settings

工具-> 兼容性视图设置