如何以编程方式禁用IE兼容性模式?

时间:2022-08-25 23:57:33

I have been stuck on this one for a while - I couldn't figure out why a website renders differently in two identical versions of Internet Explorer. Half an hour ago I came across a compatibility mode button in IE which made me really angry.

我已经被这个问题困扰了一段时间——我不明白为什么一个网站在两个相同版本的ie浏览器中呈现出不同的效果。半小时前,我在IE中发现了一个兼容模式按钮,这让我非常生气。

Disabling compatibility mode has fixed my problem.

禁用兼容性模式解决了我的问题。

Is there a way to disable it programmatically, i.e. from a web page?

是否有一种方法可以以编程方式禁用它,例如从web页面禁用它?

Edit:

编辑:

Just came across this blog https://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx

刚刚遇到这个博客https://blogs.msdn.com/b/askie/archive/2009/03/23/understand - compatibilitymodesin -internet explorer-8.aspx

I'll post an example code after reading the article

在阅读本文之后,我将发布一个示例代码

5 个解决方案

#1


88  

If you want the "old" rendering, and no button to show up on the toolbar so that users can switch modes you can use this:

如果你想要“老”渲染,并且没有按钮显示在工具栏上,这样用户可以切换模式,你可以使用这个:

<head>
  <!-- Mimic Internet Explorer 7 -->
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
  <title>My Web Page</title>
</head>

other options (old and new) include:IE=5, IE=7, IE=8, or IE=edge

其他选项(新旧)包括:IE=5, IE=7, IE=8,或IE=edge

(edge equals highest mode available)

(edge =最高模式)

#2


7  

You probably need to set your DOCTYPE correctly. Check out MSDN's articles on DOCTYPE and Defining Document Compatibility for more info.

您可能需要正确地设置DOCTYPE。查看MSDN关于DOCTYPE和定义文档兼容性的文章以获得更多信息。

#3


4  

Please also note that also IE8 browser settings can enforce a certain mode. I have a customer who has IE8 compatibility mode enforced by policy in intranet mode.

还请注意,IE8浏览器设置也可以强制执行某种模式。我有一个客户,他的IE8兼容模式在内部网模式下由策略强制执行。

#4


0  

Please add to force IE not apply Compatibility Mode

请添加到force IE不应用兼容模式。

<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

#5


0  

In my case, I fixed it by adding the following tag after the <head> tag:

在我的例子中,我在标签后面添加了以下标签:

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

#1


88  

If you want the "old" rendering, and no button to show up on the toolbar so that users can switch modes you can use this:

如果你想要“老”渲染,并且没有按钮显示在工具栏上,这样用户可以切换模式,你可以使用这个:

<head>
  <!-- Mimic Internet Explorer 7 -->
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
  <title>My Web Page</title>
</head>

other options (old and new) include:IE=5, IE=7, IE=8, or IE=edge

其他选项(新旧)包括:IE=5, IE=7, IE=8,或IE=edge

(edge equals highest mode available)

(edge =最高模式)

#2


7  

You probably need to set your DOCTYPE correctly. Check out MSDN's articles on DOCTYPE and Defining Document Compatibility for more info.

您可能需要正确地设置DOCTYPE。查看MSDN关于DOCTYPE和定义文档兼容性的文章以获得更多信息。

#3


4  

Please also note that also IE8 browser settings can enforce a certain mode. I have a customer who has IE8 compatibility mode enforced by policy in intranet mode.

还请注意,IE8浏览器设置也可以强制执行某种模式。我有一个客户,他的IE8兼容模式在内部网模式下由策略强制执行。

#4


0  

Please add to force IE not apply Compatibility Mode

请添加到force IE不应用兼容模式。

<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

#5


0  

In my case, I fixed it by adding the following tag after the <head> tag:

在我的例子中,我在标签后面添加了以下标签:

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