Html 5重置(html5reset.org) - X-UA兼容不起作用

Sun*_*oot 8 html5 internet-explorer x-ua-compatible html5boilerplate

我在html5reset.org上使用优秀的HTML 5重置模板,我的X-UA兼容元标记似乎不起作用.这是我的标题的样子:

<!DOCTYPE html>

<!--[if lt IE 7 ]> <html class="ie ieNoHtml5 ie6 no-js" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie ieNoHtml5 ie7 no-js" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie ieNoHtml5 ie8 no-js" lang="en"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie ie9 no-js" lang="en"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<!-- the "no-js" class is for Modernizr. -->

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />


    <title>Title of Page</title>
Run Code Online (Sandbox Code Playgroud)

将显示在IE中使用兼容性视图模式的选项(URL字段中的损坏的页面图标).问题是我的一些客户已经将IE9浏览器设置为"始终使用兼容性视图"模式,结果是网站看起来像IE7,即使他们使用的是IE9,而X-UA-Compatible也可以覆盖这个.

现在,如果我删除有趣的标题:

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
Run Code Online (Sandbox Code Playgroud)

......它突然开始正常工作.

我注意到html5reset.org本身似乎显示了破碎的页面图标,所以它似乎也没有工作,但html5boilerplate.com工作,似乎使用相同的方法.

通过webserver配置将X-UA-Compatible添加到响应头中似乎可以修复它,但我宁愿不依赖这种方法.


更新:似乎html5boilerplate.com只是在HTTP响应头中发送X-UA-Compatible,如果它检测到浏览器是IE.这似乎是要走的路.

Pau*_*ish 3

HTML5 Boilerplate 推荐网络服务器配置。它速度更快,并解决了标记解决方案无法使用的一些边缘情况:https://github.com/h5bp/html5-boilerplate/blob/v4.0.0/doc/html.md#x-ua-known