Html 5 Reset (html5reset.org) - X-UA-Compatible doesn't work

亡梦爱人 提交于 2019-11-30 03:41:06

问题


I'm using the excellent HTML 5 Reset template at html5reset.org and my X-UA-Compatible meta tag doesn't seem to work. Here is what my header looks like:

<!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>

The option to use compatibility view mode in IE is displayed (broken page icon in URL field). The problem is that some of my clients have set their IE9 browsers into 'always use compatibility view' mode, the result being that the website looks like IE7 even though they're using IE9, and X-UA-Compatible is suppose to override this.

Now if I remove the funny header stuff:

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

...it suddenly starts working fine.

I've noticed that html5reset.org itself seems to display the broken page icon, so it doesn't seem to work either, but html5boilerplate.com DOES work, and seems to use the same approach.

Adding the X-UA-Compatible into the response header via webserver config seems to fix it, but I'd rather not rely on this approach.


Update: It seems that html5boilerplate.com is just sending X-UA-Compatible in the HTTP response headers if it detects that the browser is IE. This seems the way to go.


回答1:


HTML5 Boilerplate recommends the webserver config. It's faster and solves a few edge cases that the markup solution doesn't work with: https://github.com/h5bp/html5-boilerplate/blob/v4.0.0/doc/html.md#x-ua-compatible



来源:https://stackoverflow.com/questions/10682827/html-5-reset-html5reset-org-x-ua-compatible-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!