Html Internet Explorer 11 通过不工作的元标记禁用“在兼容性视图中显示 Intranet 站点”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25557299/
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
Internet Explorer 11 disable "display intranet sites in compatibility view" via meta tag not working
提问by Pricey
I have been working on an intranet website for over 6 months
were I have been using the below html5 doctype
and edge compatibility meta tag to force Internet Explorer to not emulate an older browser version, and this has worked ok.
我在 Intranet 网站上工作了 6 个月以上,因为我一直在使用下面的 html5doctype
和边缘兼容性元标记来强制 Internet Explorer 不模拟旧的浏览器版本,这一切正常。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My title</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
</head>
<body>
</body>
</html>
The reason I was doing it this way is because the place I work uses a policy setting to enable compatibility view for all intranet sites, and this approach using the EDGE
setting has worked in Internet Explorer 9.
我这样做的原因是因为我工作的地方使用策略设置为所有 Intranet 站点启用兼容性视图,并且使用该EDGE
设置的这种方法在 Internet Explorer 9 中有效。
Over a month ago I was upgraded to Internet Explorer 11 and the site still worked as expected.
一个多月前,我升级到 Internet Explorer 11,该站点仍按预期运行。
Today this stopped working as expected, I can't say for sure but I think that the policy that forces the compatibility view was not enabled in IE11 and now it is... and since this has been enabled the compatibility meta tag is no longer doing what is expected, and this site is being run in the Enterprise mode which emulates IE8.
今天这停止按预期工作,我不能肯定地说,但我认为强制兼容性视图的策略在 IE11 中没有启用,现在它是......并且由于它已启用,兼容性元标记不再做预期的事情,并且此站点正在模拟 IE8 的企业模式下运行。
Does anyone know how to fix this and force IE11 to be used on an intranet site when the compatibility "Enterprise mode" is being enforced? and can't be disabled via the browser settings?
有谁知道如何解决此问题并在强制执行兼容性“企业模式”时强制在 Intranet 站点上使用 IE11?并且不能通过浏览器设置禁用?
EDIT
编辑
I have just tried adding a custom header in my web.config as explained in this answer https://stackoverflow.com/a/18257208/98706
我刚刚尝试在我的 web.config 中添加自定义标头,如本答案 https://stackoverflow.com/a/18257208/98706 中所述
and this did not work for me I still get the below message in the developer toolbar console of
这对我不起作用我仍然在开发人员工具栏控制台中收到以下消息
HTML1122: Internet Explorer is running in Enterprise Mode emulating IE8.
It is as if version 8 is being treated as the edge
when this intranet compatibility setting is enabled in IE11.
就好像版本 8 被视为edge
在 IE11 中启用此 Intranet 兼容性设置时。
This post: https://www.leapinggorilla.com/Blog/Read/1016/ie-ate-my-css---disabling-compatability-modeexplains this well, I haven't yet tried setting this header via code and our users dont have access to change their browser settings.. none of the other changes have worked as yet.
这篇文章:https: //www.leapinggorilla.com/Blog/Read/1016/ie-ate-my-css---disabling-compatability-mode很好地解释了这一点,我还没有尝试通过代码和我们的用户无权更改他们的浏览器设置.. 其他更改都还没有奏效。
UPDATE
更新
Please see my comment on this post about what the difference between Enterprise mode and compatibility mode is, because it is important.
请参阅我对这篇文章的评论,了解企业模式和兼容模式之间的区别,因为它很重要。
采纳答案by sparrowt
Make sure:
确保:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
is the first <meta>
tag on your page, otherwise IE may not respect it.
是<meta>
页面上的第一个标签,否则 IE 可能不会尊重它。
Alternatively, the problem may be that IE is using Enterprise Modefor this website:
或者,问题可能是 IE 正在为此网站使用企业模式:
- Your question mentioned that the console shows:
HTML1122: Internet Explorer is running in Enterprise Mode emulating IE8.
- If so you may need to disable enterprise mode(or like this) or turn it off for that website from the Tools menu in IE.
- However Enterprise Mode shouldin theory be overridden by the X-UA-Compatible tag, but IE might have a bug...
回答by rustyx
This problem is generally caused by the website/intranet URL being placed in one of:
此问题通常是由于网站/内网 URL 被放置在以下之一中引起的:
- Compatibility Mode List
- Internet Explorer Intranet Zone
(with Display intranet sites in Compatibility Viewsetting enabled) - Enterprise Mode List
- 兼容模式列表
- Internet Explorer Intranet 区域
(启用在兼容性视图设置中显示 Intranet 站点) - 企业模式列表
On corporate networks, these compatibility view settings are often controlled centrally via group policy. In your case, Enterprise Modeappears to be the culprit.
在公司网络上,这些兼容性视图设置通常通过组策略集中控制。在您的情况下,企业模式似乎是罪魁祸首。
Unfortunately setting META X-UA-Compatible
will not overridethis.
不幸的是,设置 METAX-UA-Compatible
不会覆盖它。
For End-Users
对于最终用户
Sometimes the only way for end-users to override this is to press F12 and change the Document Modeunder the EmulationTab. However this setting is not permanent and may revert once Developer Tools is closed.
有时,最终用户覆盖此设置的唯一方法是按 F12 并更改仿真选项卡下的文档模式。但是,此设置不是永久性的,一旦开发者工具关闭,它可能会恢复。
You can also try to exclude your site from the Intranet zone. But the list of domains which belong to the Intranet zone is usually also controlled by the group policy, so the chance of this working is slim.
您也可以尝试从 Intranet 区域中排除您的站点。但是属于 Intranet 区域的域列表通常也受组策略控制,因此这种工作的可能性很小。
To see the list of domains that belong to the Intranet zone, go to:
要查看属于 Intranet 区域的域列表,请访问:
Tools -> Internet Options -> Security -> Sites -> Advanced
工具 -> Internet 选项 -> 安全 -> 站点 -> 高级
If the list contains your subdomain and is greyed out, then you will not be able to override compatibility view until your network admin allows it.
如果列表包含您的子域并且显示为灰色,则在您的网络管理员允许之前,您将无法覆盖兼容性视图。
You really need to contact your network administrator to allow changing the compatibility view settings in the group policy.
您确实需要联系您的网络管理员以允许更改组策略中的兼容性视图设置。
For Network Admins
对于网络管理员
Loading the website with Developer Tools open (F12) will often report the reason that IE is switching to an older mode.
在打开开发工具 (F12) 的情况下加载网站通常会报告 IE 切换到旧模式的原因。
All 3 settings mentioned above are generally controlled via Group Policy, although can sometimes be overridden on user machines.
上面提到的所有 3 个设置通常都通过组策略控制,尽管有时可以在用户计算机上覆盖。
If Enterprise Modeis the issue (as appears to be the case for the original poster), the following two articles might be helpful:
如果企业模式是问题所在(原始海报似乎就是这种情况),以下两篇文章可能会有所帮助:
- How to Enable and Use Internet Explorer 11's Enterprise Mode[HowToGeek]
- Turn on Enterprise Mode and use a site list[TechNet]
- 如何启用和使用 Internet Explorer 11 的企业模式[HowToGeek]
- 打开企业模式并使用站点列表[TechNet]
回答by Jason Marsell
For those who are building an ASP.NET MVC project, make sure that you add the:
对于那些正在构建 ASP.NET MVC 项目的人,请确保添加:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
tag into your Layout (template) page. I just spent two hours debugging and tweaking, only to realize that I had only added that meta tag into my child pages. As soon as I added it to my layout page, the browser loaded in EDGE mode perfectly.
标记到您的布局(模板)页面。我只花了两个小时调试和调整,才意识到我只是在我的子页面中添加了那个元标记。一旦我将它添加到我的布局页面,浏览器就会完美地以 EDGE 模式加载。
回答by ch1nmuzak
The marked answer is the correct one. However, Pricey, you should follow up on this with your AD and desktop admin groups. They are misusing the IE11 Enterprise Mode site list. Microsoft does NOT intend it to be used for all intranet sites within an organization at all. That would be propagating the existing "render all intranet sites in compatibility mode" setting that is the bane of corporate website advancement the world over.
标记的答案是正确的。但是,Pricey,您应该跟进您的 AD 和桌面管理员组。他们滥用 IE11 企业模式站点列表。Microsoft 根本不打算将其用于组织内的所有 Intranet 站点。这将传播现有的“以兼容模式呈现所有 Intranet 站点”设置,这是全球企业网站发展的祸根。
It's meant to implemented as a "Black list", with the handful of sites that actually require a legacy browser mode listed in the Enterprise Mode list with their rendering requirements specified. All other sites in your organization are then freed up to use Edge. The people in your organization who implemented it with all intranet sites included to start with have completely misunderstood how Enterprise Mode is meant to be implemented.
它旨在作为“黑名单”实现,其中少数几个实际需要旧浏览器模式的站点列在企业模式列表中,并指定了它们的渲染要求。然后,您组织中的所有其他站点都可以自由使用 Edge。贵组织中最初通过所有 Intranet 站点实施它的人员完全误解了企业模式的实施方式。
回答by Dean P
This is an old problem with some good information. But what I just found is that using a FQDN turns off the Compat mode in IE 9 - 11.
Example. I have the compat problem with
http://lrmstst01:8080/JavaWeb/login.do
but the problems go away with
http://lrmstst01.mydomain.int:8080/JavaWeb/login.do
NB: The .int is part of our internal domain
这是一个老问题,有一些很好的信息。但我刚刚发现使用 FQDN 会关闭 IE 9 - 11 中的兼容模式。示例。我有
http://lrmstst01:8080/JavaWeb/login.do的兼容问题,
但问题消失了
http://lrmstst01.mydomain.int:8080/JavaWeb/login.do
注意:.int 是我们的内部域
回答by Mike Anderson
The question is a bit old but I just solved a very similar problem. We have several intranet sites here including the one I'm responsible for, and the others require compatibility mode or they break. For that reason, site rules default IE to compatibility mode on intranet sites. I am upgrading my own stuff and no longer need it; in fact, some of the features I'm trying to use don't look right in compat mode. I'm using the meta IE-Edge tag like you are.
这个问题有点老了,但我刚刚解决了一个非常相似的问题。我们这里有几个 Intranet 站点,包括我负责的一个站点,其他站点需要兼容模式,否则它们会损坏。因此,站点规则默认 IE 为 Intranet 站点上的兼容模式。我正在升级自己的东西,不再需要它;事实上,我尝试使用的某些功能在兼容模式下看起来并不正确。我像你一样使用元 IE-Edge 标签。
IE assumes websites without the fully-qualified address are intranet, and acts accordingly. With that in mind I just altered the bindings in IIS to only listen to the fully-qualified address, then set up a dummy website that listened for the unqualified address. The second one redirects all traffic to the fully-qualified address, making IE believe it's an external site. The site renders correctly with or without the Compatibility Mode on Intranet Sites box checked.
IE 假定没有完全限定地址的网站是 Intranet,并采取相应的行动。考虑到这一点,我只是将 IIS 中的绑定更改为仅侦听完全合格的地址,然后设置一个侦听不合格地址的虚拟网站。第二个将所有流量重定向到完全合格的地址,使 IE 相信它是一个外部站点。无论是否选中 Intranet 站点上的兼容模式框,该站点都可以正确呈现。
回答by Greg C.
Move it to the Trusted Sites zone by either adding it to a Trusted Sites list or local setting. This will move it out of Intranet Zone and will not be rendered in Compat. View.
通过将其添加到受信任站点列表或本地设置,将其移动到受信任站点区域。这会将其移出 Intranet 区域,并且不会在 Compat 中呈现。看法。
回答by user942620
Add the below property into the web.config file for IIS sites. This worked for me on my intranet in IE11.
将以下属性添加到 IIS 站点的 web.config 文件中。这在我的 IE11 内联网上对我有用。
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
回答by thecarpy
I solved this issue by redirecting the user to the FQDN of the server hosting the intranet.
我通过将用户重定向到托管 Intranet 的服务器的 FQDN 解决了这个问题。
IE probably uses the world's worst algorithm for detecting "intranet" sites ... indeed, specifying server.domain.tld solves the problem for me.
IE 可能使用了世界上最糟糕的算法来检测“内联网”站点……确实,指定 server.domain.tld 为我解决了这个问题。
Yes, you read that correctly, IE detects intranet sites not by private IP address, like any dev who has heard of TCP/IP would do, no, by the "host" part of the URL, if it has no domain part, must be internal.
是的,你没看错,IE 不是通过私有 IP 地址检测 Intranet 站点,就像任何听说过 TCP/IP 的开发人员一样,不,通过 URL 的“主机”部分,如果它没有域部分,则必须是内部的。
Scary to know the IE devs do not understand the most basic TCP/IP concepts.
可怕的是,IE 开发者不了解最基本的 TCP/IP 概念。
Note that this was at a BIG enterprise customer, getting them to change GPO for you is like trying to move the Alps east by 4 meters, not gonna happen.
请注意,这是在一个大企业客户那里,让他们为您更改 GPO 就像试图将阿尔卑斯山向东移动 4 米,这不会发生。
回答by Yann Vo
For what it's worth, I had the issue as well in IE11:
对于它的价值,我在 IE11 中也遇到了这个问题:
- I was notin Enterprise mode.
- The "Display intranet sites in Compatibility View" was checked.
- I had all the
<!DOCTYPE html>
andIE=Edge
settings mentioned in the question - The meta header was indeed the 1st element in the
<head>
element
- 我没有处于企业模式。
- 勾选了“在兼容性视图中显示 Intranet 站点”。
- 我有问题中提到的所有
<!DOCTYPE html>
和IE=Edge
设置 - 元标题确实是元素中的第一个
<head>
元素
After a while, I found out that:
一段时间后,我发现:
- the User Agent header sent to the server was IE7 but...
- the JavaScript value was IE11!
- 发送到服务器的用户代理标头是 IE7但...
- JavaScript 值为 IE11!
HTTP Header:
HTTP 标头:
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E)
but
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E)
但
JavaScript:
JavaScript:
window.navigator.userAgent === 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko'
window.navigator.userAgent === 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko'
So I ended up doing the check on the client side.
所以我最终在客户端进行了检查。
And BTW, meanwhile, checking the user agent is no longer recommended. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent(but there might be a good case)
顺便说一句,与此同时,不再推荐检查用户代理。请参阅https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent(但可能有一个很好的案例)