Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer 如何防止IE9以兼容模式呈现intranet站点_Internet Explorer_Internet Explorer 9_Compatibility Mode_Ie Compatibility Mode - Fatal编程技术网

Internet explorer 如何防止IE9以兼容模式呈现intranet站点

Internet explorer 如何防止IE9以兼容模式呈现intranet站点,internet-explorer,internet-explorer-9,compatibility-mode,ie-compatibility-mode,Internet Explorer,Internet Explorer 9,Compatibility Mode,Ie Compatibility Mode,IE9有一个奇怪的问题,它以兼容模式呈现内部网站点 有人知道如何防止这种情况发生吗 注意:我不是在寻找一种在单用户计算机上阻止它的方法,而是寻找一些编程方法来防止站点在兼容模式下呈现。这可以通过添加一个简单的元标记来实现 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 另一种方法是将此代码添加到.htaccess文件中 # ---------------------------------------

IE9有一个奇怪的问题,它以兼容模式呈现内部网站点

有人知道如何防止这种情况发生吗


注意:我不是在寻找一种在单用户计算机上阻止它的方法,而是寻找一些编程方法来防止站点在兼容模式下呈现。

这可以通过添加一个简单的元标记来实现

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

另一种方法是将此代码添加到.htaccess文件中

# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------

# Force the latest IE version, in various cases when it may fall back to IE7 mode
#  github.com/rails/rails/commit/123eb25#commitcomment-118920
# Use ChromeFrame if it's installed for a better experience for the poor IE folk

<IfModule mod_headers.c>
  Header set X-UA-Compatible "IE=Edge,chrome=1"
  # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>
#----------------------------------------------------------------------
#为IE用户提供更好的网站体验
# ----------------------------------------------------------------------
#强制使用最新的IE版本,在各种情况下可能会退回到IE7模式
#github.com/rails/rails/commit/123eb25#commitcomment-118920
#如果安装ChromeFrame是为了给穷人带来更好的体验,请使用它
标题集X-UA-兼容“IE=Edge,chrome=1”
#mod_标题无法按内容类型匹配,但我们不希望在*everything*…上发送此标题。。。
标题未设置X-UA-Compatible

如果可以向主页添加代码,只需添加以下内容:

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

到您网站的标题

(也可以使用
强制IE9渲染器) 这将强制IE9以标准模式渲染

另一种方法是使用另一个doctype: 将此项放在代码的顶部:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

在彻底搜索之后,我找到了如何在IE9中成功阻止intranet站点以兼容模式呈现的方法:

来自特斯蒙德的博客

IE9中有两个怪癖会导致兼容模式保持有效。 X-UA兼容元元素必须是head部分中的第一个元元素。 在X-UA-Compatible元元素之前不能有条件IE语句。 这意味着,如果您使用Paul Irish的精彩HTML5样板,那么在具有默认IE9设置的Intranet上,您的网站将以兼容模式显示。您需要从以下内容更改样板文件的开头:-

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

致:


根据@nearyerprgrmr的回答,似乎有一个解决办法,可以让IE9在IE7模式下加载内部网。虽然这仍然会触发兼容性模式,但我发现对IE9进行了一个小小的修改,至少允许IE9在IE9标准中呈现内部网:

<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
</head>
<!--[if lt IE 7]>   <body class="home lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>      <body class="home lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>      <body class="home lt-ie9"> <![endif]-->
<!--[if IE 9]>      <body class="home lt-ie10"><![endif]-->
<!--[if gt IE 9]><!--> <body class="home"> <!--<![endif]-->

    <p>content</p>

</body>
</html>

内容


这仍然是有效的HTML,并且现有的特定于IE的CSS应该仍然可以正常工作,前提是您使用
.lt IE
而不是
HTML.lt IE

刚刚尝试了IE edge和IE-9两种方法。两者都不起作用。我需要将meta标记放在
右侧?是的,在
标记的内部(下方)。如果它不起作用,请删除您的doctype并将其替换为:
刚刚尝试添加meta标记。虽然没有解决问题,但我没有访问我的htaccess文件的权限。您确定meta标记适用于intranet站点吗?我知道它是否适用于常规站点,但不确定是否适用于内部网。您是否尝试过清除所有临时internet文件,甚至在其他电脑上测试它?是的,实际上是在其他电脑上测试过。我做了更多的研究,实际上我不知道在IE9中覆盖内联网兼容模式的可能性。这有多彻底?我不确定这是一对“怪癖”还是一对“bug”。:)谢谢你给我指点这篇文章。我在下面找到了IE7渲染问题的解决方法,如果你可以使用兼容模式的话……谢谢@nearyorprgrmr!这并不会阻止我使用兼容模式,但它会以Internet Explorer 9文档模式呈现页面,这正是我所需要的。这最初对我不起作用。但是在进一步阅读之后,我发现X-UA兼容的元元素不仅必须是head部分中的第一个元元素,还应该是head部分中进行任何渲染的第一个元素。我有一个链接标签在前面。一旦我交换了它们,我就让IE9在IE9模式下运行,而不是在IE7兼容模式下运行。是的,这是有效的,秘密是让你的条件语句在你的头标签之外。
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
</head>
<!--[if lt IE 7]>   <body class="home lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>      <body class="home lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>      <body class="home lt-ie9"> <![endif]-->
<!--[if IE 9]>      <body class="home lt-ie10"><![endif]-->
<!--[if gt IE 9]><!--> <body class="home"> <!--<![endif]-->

    <p>content</p>

</body>
</html>