Force IE compatibility mode off using tags

2018-12-31 09:32发布

I am doing work for a client who forces compatibility mode on all intranet sites. I was wondering if there is a tag I can put into my HTML that forces compatibility mode off.

12条回答
余欢
2楼-- · 2018-12-31 10:05

IE8 defaults to standards mode for the intERnet and quirks mode for the intRAnet. The HTML meta tag is ignored if you have the doctype set to xhtml transitional. The solution is to add an HTTP header in code. This worked for us. Now our intranet site is forcing IE8 to render the app in standards mode.

Added to PageInit of the base page class (ASP.net C#):

Response.AddHeader("X-UA-Compatible", "IE=EmulateIE8");

reference: http://ilia.ws/archives/196-IE8-X-UA-Compatible-Rant.html

查看更多
素衣白纱
3楼-- · 2018-12-31 10:09

This is due to the setting within IE Compatibility settings which says that all Intranet sites should run in compatibility mode. You can untick this via a group policy (or just plain unticking it in IE), or you can set the following:

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

Apparently it is not possible to change the compatibility view settings as a group policy but it is something that can perhaps be changed in the registry, this meta tag works fine for me, I had to make the required attribute work as part of a html form, it worked in chrome and firefox but not IE.

Here is a nice visual of what browsers support each individual html 5 element.

http://html5readiness.com/

Notice the one common denominator Google Chrome, it supports everything. Hope this is of help

查看更多
看风景的人
4楼-- · 2018-12-31 10:14

If you have access to the server, the most reliable way of doing this is to do it on the server itself, in IIS. Go in to IIS HTTP Response Headers. Add Name: X-UA-Compatible
Value: IE=edge This will override your browser and your code.

查看更多
妖精总统
5楼-- · 2018-12-31 10:17

If you're working with a page in the Intranet Zone, you may find that IE9 no matter what you do, is going into IE7 Compat mode.

This is due to the setting within IE Compatibility settings which says that all Intranet sites should run in compatibility mode. You can untick this via a group policy (or just plain unticking it in IE), or you can set the following:

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

This works (as detailed in other answers), but may not initially appear so: it needs to come before the stylesheets are declared. If you don't, it is ignored.

查看更多
看淡一切
6楼-- · 2018-12-31 10:17

If you want each individual web page to load the chosen content and are using asp.net. Just apply it as the first tag under the heading tag in Views>shared>Layout.cshtml

just a tip

查看更多
大哥的爱人
7楼-- · 2018-12-31 10:21

I believe this will do the trick:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
查看更多
登录 后发表回答