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

时间:2012-05-21 09:39:19

标签: html5 internet-explorer html5boilerplate x-ua-compatible

我正在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>

显示在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" />

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

我注意到html5reset.org本身似乎显示了损坏的页面图标,所以它似乎也不起作用,但是html5boilerplate.com可以工作,并且似乎使用相同的方法。 / p>

通过webserver配置将X-UA-Compatible添加到响应头中似乎解决了这个问题,但我宁愿不依赖这种方法。


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

1 个答案:

答案 0 :(得分:3)

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

相关问题