IE兼容模式:“X-UA-兼容”标签“边缘”

发布于 2024-10-04 00:04:26 字数 214 浏览 3 评论 0原文

我在 中有这个:

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

它将强制 IE 使用最新的渲染模式,但兼容模式是否被认为是最后一个?

我的意思是,例如:在 IE8 上使用此代码,它会强制它使用 IE8 或 IE8 兼容模式?

I have this in the <head>:

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

It will force the latest rendering mode for IE, but is Compatibility Mode considered the last one?

I mean, for example: using this code with IE8, it will force it to use IE8 or IE8 Compatibility Mode?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

×纯※雪 2024-10-11 00:04:26

该标签将尝试强制浏览器使用浏览器支持的最新渲染模式。它不会触发兼容模式。

请注意,该标签必须是头部的第一个标签,否则它将不起作用。
如果可能的话,这一事实有利于使用 HTTP 标头,因为 HTTP 标头中的顺序并不重要。

如果当您使用标头或元标记时,浏览器仍然最终处于兼容模式,原因之一可能是:

  • 您缺少合理的文档类型,
  • 浏览器已设置为始终使用兼容模式,
  • 该网站托管在“ Intranet 站点”,并且 Intranet 站点的默认设置为

更改浏览器兼容性视图设置

Microsoft 认为至少 192.168.xx 位于“Intranet 站点”上。 IE8/IE9 中的 Intranet 站点默认使用兼容模式。对于许多业务应用程序来说,这是一个巨大的问题,因为即使使用此元标记,程序员也无法覆盖此选项。 (“在兼容性视图中显示 Intranet 站点”不能被元标记或 http 标头覆盖 - 在这种情况下,浏览器完全控制兼容性视图)

兼容性视图设置

始终添加此元标记或 http 标头?

使用此元标记的另一个好处是“兼容性视图”图标从地址栏中删除浏览器。至少您的用户无法使用该按钮决定渲染模式。

That tag will try to force the browser to use the latest rendering mode the browser supports. It will not trigger Compatibility mode.

Note that the tag has to be the first tag in the head or it will not work.
This fact favors using HTTP headers if possible as the order in the HTTP headers does not matter.

If the browser stills ends up in Compatibility mode when you use a header or the meta tag one of these things is likely the cause:

  • you are missing a sane doctype
  • the browser has been set to always use compatibility mode
  • the site is hosted on an "intranet site" and the default setting for intranet sites is set

Changing the browsers Compatibility View settings

Microsoft considers at least 192.168.x.x to be on a "Intranet site". The default for intranet sites in IE8/IE9 is to use compatibility mode. That's a huge issue for many business applications as the programmer CANNOT override this option even with this meta tag. ("Display intranet sites in Compatitiblity View" is not overridable by meta tag or http header - the browser is in complete control of compatibility view in this case)

Compatibility View Settings

Always add this meta tag or an http header?

One more good thing about using this meta tag is that the "compatibilty view" icon is removed from the address bar of the browser. At least your users can then not decide the render mode using that button.

浮萍、无处依 2024-10-11 00:04:26

即使您未选中“在兼容性视图中显示 Intranet 站点”选项,并且响应标头中包含 X-UA-Compatible,您的浏览器仍可能默认为“兼容性视图”还有另一个原因 - 您的组策略。查看您的控制台是否有以下消息:

HTML1203:xxx.xxx 已配置为通过组策略在兼容性视图中运行。

其中 xxx.xxx 是您网站的域名(即 test.com)。如果您看到此内容,则说明您的域的组策略已设置,以便任何以 test.com 结尾的网站都将自动以兼容模式呈现,无论文档类型、标头等如何。

有关详细信息,请参阅以下链接(解释了 html 代码) ): http://msdn.microsoft. com/en-us/library/ie/hh180764(v=vs.85).aspx

Even if you have unchecked the "Display intranet sites in Compatibility View" option, and have the X-UA-Compatible in your response headers, there is another reason why your browser might default to "Compatibility View" anyways - your Group Policy. Look at your console for the following message:

HTML1203: xxx.xxx has been configured to run in Compatibility View through Group Policy.

Where xxx.xxx is the domain for your site (i.e. test.com). If you see this then the group policy for your domain is set so that any site ending in test.com will automatically render in Compatibility mode regardless of doctype, headers, etc.

For more information, please see the following link (explains the html codes): http://msdn.microsoft.com/en-us/library/ie/hh180764(v=vs.85).aspx

骄兵必败 2024-10-11 00:04:26

我不是专家,但通过反复试验:

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

为我解决了问题。我在网站和网络应用程序上使用了它,它阻止了 IE8 进入兼容模式,并在 IE10 和 IE11 中显示为“标准”。

I'm not an expert but by trial and error:

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

solved the problem for me. I used this on websites and webapps and it stopped IE8 from going into compatibility mode, and displayed as 'standard' in IE10 and IE11.

疾风者 2024-10-11 00:04:26

单独使用 Edge 关键字有什么意义?我的意思是,如果您希望 IE 使用最新的渲染引擎,那么只需删除整个元标记即可。

否则,它应该看起来像这样(这将使 IE8 的行为类似于 IE7 和 IE9,更新版本将照常工作):

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, IE=Edge" />

What is the point of using the Edge keyword alone? I mean, if you want IE to use the most recent rendering engine, then just drop the whole meta tag.

Otherwise, it should look something like that (that would make IE8 behave like IE7 and IE9 and newer will work as usual) :

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, IE=Edge" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文