I'm using the HTML5 doctype with X-UA-Compatible meta tag near the top:
我使用的HTML5 doctype与x - ua兼容的meta标记接近顶部:
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en-us" class="ie6"> <![endif]-->
<!--[if IE 7]> <html lang="en-us" class="ie7"> <![endif]-->
<!--[if IE 8]> <html lang="en-us" class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
...
But Internet Explorer 9 for some users is rendering the page in compatibility view. I suspect it's because they have the "Display all websites in Compatibility View" setting turned on. Is there a way to force IE9 to use IE9 Browser and Document Mode?
但是对于一些用户来说,Internet Explorer 9正在兼容性视图中呈现页面。我怀疑这是因为他们有“显示所有网站兼容性视图”的设置。有没有办法强制IE9使用IE9浏览器和文档模式?
7 个解决方案
#1
25
It turns out that the solution is to set X-UA-Compatible in the HTTP header and not in the HTML:
结果是,解决方案是在HTTP头中设置x - ua兼容,而不是在HTML中:
X-UA-Compatible: IE=edge,chrome=1
This will force Internet Explorer to use the latest rendering engine, even if "Display all websites in Compatibility View" is turned on.
这将迫使Internet Explorer使用最新的呈现引擎,即使“在兼容性视图中显示所有网站”被打开。
#2
10
It's also working with this in <head>
in html:
它还在 html中使用:
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
#3
5
The X-UA-COMPATIBLE meta tag has to be the first tag inside the head, or else it will not work. See this answer: https://*.com/a/22233206/3329906.
x - ua兼容的元标签必须是头里面的第一个标签,否则它就不能工作。看到这个答案:https://*.com/a/22233206/3329906。
All this http header stuff is overkill.
所有这些http头内容都是多余的。
#4
3
please append in head section of your website, hope it helps.
请在你的网站的标题部分添加,希望能有所帮助。
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=5, IE=7, IE=8, IE=9, IE=10" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
#5
1
As JohnnyO says it has to be sent as a header. In PHP add this (before any other output is sent):
正如JohnnyO所说,它必须作为标题发送。在PHP中添加这个(在发送任何其他输出之前):
<?php header( 'X-UA-Compatible: IE=edge,chrome=1' ); ?>
In Wordpress this would probably be best if you put it as the very first line in your header.php
file as long as you don't have any output (or errors) before that file is rendered it should work.
在Wordpress中,如果你把它作为标题的第一行,这可能是最好的。php文件,只要在呈现该文件之前没有任何输出(或错误),它就应该工作。
If you have errors being output to the browser you may want to tell errors to be logged only and not output to the screen by adding something like this to your application:
如果有错误输出到浏览器,您可能希望通过向应用程序添加以下内容来告知错误只被记录,而不是输出到屏幕:
ini_set('display_errors', 0);
ini_set('log_errors', 1);
In Wordpress that could be added near the top of the wp-config.php
file.
在Wordpress中,这可以添加到wp-config的顶部。php文件。
If you have caching enabled with something like WP SuperCache or W3 Total Cache all bets are off regarding the behavior of your site - you'll need to do some searching for how to add extra headers with your caching plugin.
如果使用WP超级缓存或W3总缓存之类的东西启用缓存,那么您的站点的行为就不存在了——您需要进行一些搜索,以了解如何在缓存插件中添加额外的标题。
#6
0
@netzaffin is right - if X-UA-Compatible is the first meta tag in HEAD section, IE9 works.
@netzaffin是对的——如果X-UA-Compatible是HEAD部分中的第一个元标签,IE9就会工作。
#7
0
Only adding
只添加
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
will do ;)
会做,)
For eg:
如:
<!DOCTYPE html>
<html lang="en-US" class="css3transitions">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
#1
25
It turns out that the solution is to set X-UA-Compatible in the HTTP header and not in the HTML:
结果是,解决方案是在HTTP头中设置x - ua兼容,而不是在HTML中:
X-UA-Compatible: IE=edge,chrome=1
This will force Internet Explorer to use the latest rendering engine, even if "Display all websites in Compatibility View" is turned on.
这将迫使Internet Explorer使用最新的呈现引擎,即使“在兼容性视图中显示所有网站”被打开。
#2
10
It's also working with this in <head>
in html:
它还在 html中使用:
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
#3
5
The X-UA-COMPATIBLE meta tag has to be the first tag inside the head, or else it will not work. See this answer: https://*.com/a/22233206/3329906.
x - ua兼容的元标签必须是头里面的第一个标签,否则它就不能工作。看到这个答案:https://*.com/a/22233206/3329906。
All this http header stuff is overkill.
所有这些http头内容都是多余的。
#4
3
please append in head section of your website, hope it helps.
请在你的网站的标题部分添加,希望能有所帮助。
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=5, IE=7, IE=8, IE=9, IE=10" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
#5
1
As JohnnyO says it has to be sent as a header. In PHP add this (before any other output is sent):
正如JohnnyO所说,它必须作为标题发送。在PHP中添加这个(在发送任何其他输出之前):
<?php header( 'X-UA-Compatible: IE=edge,chrome=1' ); ?>
In Wordpress this would probably be best if you put it as the very first line in your header.php
file as long as you don't have any output (or errors) before that file is rendered it should work.
在Wordpress中,如果你把它作为标题的第一行,这可能是最好的。php文件,只要在呈现该文件之前没有任何输出(或错误),它就应该工作。
If you have errors being output to the browser you may want to tell errors to be logged only and not output to the screen by adding something like this to your application:
如果有错误输出到浏览器,您可能希望通过向应用程序添加以下内容来告知错误只被记录,而不是输出到屏幕:
ini_set('display_errors', 0);
ini_set('log_errors', 1);
In Wordpress that could be added near the top of the wp-config.php
file.
在Wordpress中,这可以添加到wp-config的顶部。php文件。
If you have caching enabled with something like WP SuperCache or W3 Total Cache all bets are off regarding the behavior of your site - you'll need to do some searching for how to add extra headers with your caching plugin.
如果使用WP超级缓存或W3总缓存之类的东西启用缓存,那么您的站点的行为就不存在了——您需要进行一些搜索,以了解如何在缓存插件中添加额外的标题。
#6
0
@netzaffin is right - if X-UA-Compatible is the first meta tag in HEAD section, IE9 works.
@netzaffin是对的——如果X-UA-Compatible是HEAD部分中的第一个元标签,IE9就会工作。
#7
0
Only adding
只添加
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
will do ;)
会做,)
For eg:
如:
<!DOCTYPE html>
<html lang="en-US" class="css3transitions">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />