X-UA-Compatible 设置为 IE=edge,但它仍然没有停止兼容模式 [英] X-UA-Compatible is set to IE=edge, but it still doesn't stop Compatibility Mode

查看:30
本文介绍了X-UA-Compatible 设置为 IE=edge,但它仍然没有停止兼容模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑.我应该可以设置

I am quite confused. I should be able to set

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

和 IE8 和 IE9 应该使用最新的渲染引擎来渲染页面.但是,我只是对其进行了测试,如果在我们网站的其他地方打开了兼容模式,它将在 我们的页面上保持打开状态,即使我们应该强迫它不这样做.

and IE8 and IE9 should render the page using the latest rendering engine. However, I just tested it, and if Compatibility Mode is turned on elsewhere on our site, it will stay on for our page, even though we should be forcing it not to.

您应该如何确保 IE 使用兼容模式(即使在 Intranet 中)?

How are you supposed to make sure IE does not use Compatibility Mode (even in an intranet)?

FWIW,我正在使用 HTML5 DocType 声明().

FWIW, I am using the HTML5 DocType declaration (<!doctype html>).

这是页面的前几行:

<!doctype html> 
<!--[if lt IE 7 ]> <html lang="en" class="innerpage no-js ie6"> <![endif]--> 
<!--[if IE 7 ]>    <html lang="en" class="innerpage no-js ie7"> <![endif]--> 
<!--[if IE 8 ]>    <html lang="en" class="innerpage no-js ie8"> <![endif]--> 
<!--[if (gte IE 9)|!(IE)]><!--> 
<html lang="en" class="innerpage no-js"> 
<!--<![endif]--> 
    <head> 
        <meta charset="ISO-8859-1" /> 
        <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 

我刚刚了解到默认设置IE8是对内网站点使用IE7兼容模式.这会覆盖 X-UA-Compatible 元标记吗?

I just learned that the default setting on IE8 is to use IE7 compatibility mode for intranet sites. Would this override the X-UA-Compatible meta tag?

推荐答案

如果您需要为 Intranet 站点覆盖 IE 的兼容性视图设置,您可以在 web.config (IIS7) 中或通过 自定义 HTTP 标头 在网站的属性 (IIS6) 中并在那里设置 X-UA-Compatible.元标记不会覆盖兼容性视图设置中的 IE 内网设置,但如果您在托管服务器上设置它,它将覆盖兼容性.

If you need to override IE's Compatibility View Settings for intranet sites you can do so in the web.config (IIS7) or through the custom HTTP headers in the web site's properties (IIS6) and set X-UA-Compatible there. The meta tag doesn't override IE's intranet setting in Compatibility View Settings, but if you set it at the hosting server it will override the compatibility.

IIS7 中的 web.config 示例:

Example for web.config in IIS7:

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

编辑:我删除了 add 之前的 clear 代码;这是复制和粘贴过程中不必要的疏忽.好收获,评论者!

Edit: I removed the clear code from just before the add; it was an unnecessary oversight from copying and pasting. Good catch, commenters!

这篇关于X-UA-Compatible 设置为 IE=edge,但它仍然没有停止兼容模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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