与HTTP头的X UA兼容 [英] X-UA-Compatibility with HTTP Header

查看:289
本文介绍了与HTTP头的X UA兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我在使用IE浏览器中的一个网站,是不是在内部网和始终显示在兼容模式下的网页没有被激活,但它在特殊模式还是打开有时,尽管加入

actually i'm having a problem with a website in IE which is not on intranet and the "always show pages in compatibility mode is not activated" but it still opens in quirks mode sometimes, despite adding

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

我有红色的,我可以在HTTP报头或htaccess的发送该兼容性为了

I have red that i can send this compatibility order in an HTTP Header or in htaccess

我的问题是我已经寻找了如何发送一个HTTP头居然没有发现线索,并顺便说一句我是一个PHP开发人员,以防万​​一这些信息是必要的。

My problem is that i have searched on how to send an HTTP header and actually found no clue, and btw i'm a php developer just in case this information was necessary.

我真的AP preciate,如果有人能提供给我什么是需要添加(两个,或者至少有一),以及如何/在哪里添加它,我一直在寻找了整整一个星期,它的安静迫切找到了修正这么快!

I would really appreciate if someone could provide me what's needed to add (for both, or for one at least) and how/where to add it, i have been looking for the whole week and it's quiet urgent to find the fix so soon !

时的这种方式它作为一个HTTP标头在该页面的第一行是正确发送?

Is this way to send it as an HTTP header as a first line in the page is right ?

<?php
header('X-UA-Compatible: IE=edge');
?>

(我刚刚发现它)

(I have just found it)

我真的AP preciate任何帮助可以提供,我很感谢提前。

I really appreciate any help can be provided and i'm thankful in advance.

推荐答案

正如你指出正确的标题可以在PHP中设置:

As you correctly noted the header can be set in php:

<?php header('X-UA-Compatible: IE=edge,chrome=1');

也可以在的.htaccess 设置像这样:

<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 "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>

(从复制HTML5样板模板)

然而后,如果您要设置这些头,并发现IE浏览器仍然默认为怪癖模式的话,我会倾向于认为还有别的东西在起作用。你确保你的网页中包含有效的 DOCTYPE ?值得注意的是一个不是的HTML 4.01的味道。

However, if you are setting these headers and finding that IE still defaults to quirks-mode then I'd be inclined to suggest that there is something else at work. Have you ensured that your pages include a valid doctype? Notably one that isn't of the HTML 4.01 flavour.

这篇关于与HTTP头的X UA兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆