css - html 条件语句 hack 在实时时将 IE 视为错误版本

标签 css internet-explorer internet-explorer-9

基本上,我正在针对不同版本的 IE 优化网站。我正在使用 IE9(通过 IE 的关于页面验证)。

本地(使用 xampp)网站正确检测到浏览器是 IE9 并加载正确的 css 代码。但是,当我将代码放到文本服务器上时,它会将浏览器视为 IE7。

对于测试:

我使用 xmapp 在本地获得的输出

According to the conditional comment this is IE
According to the conditional comment this is IE 9
According to the conditional comment this is IE 8 or higher
According to the conditional comment this is IE greater than 6

我在测试服务器上得到的输出:

According to the conditional comment this is IE
According to the conditional comment this is IE 7
According to the conditional comment this is IE lower than 9
According to the conditional comment this is IE lower or equal to 7
According to the conditional comment this is IE greater than 6

关于问题可能是什么的任何想法?

编辑:我用来检查版本的内容

<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE<br />
<!-- <![endif]-->

最佳答案

尝试将此元添加到您的头部部分:

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

还有这个文档类型:

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

关于css - html 条件语句 hack 在实时时将 IE 视为错误版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8187346/

相关文章:

html - Phonegap 联系人列表按字母顺序快速滚动?

javascript - 是否可以为您网站的特定部分制作图片?

internet-explorer - PowerShell Internet Explorer Com 对象选择类下拉菜单项

javascript - jQuery SelectBox 插件在 IE7、8 或 9 中不起作用

css - 在 IE9 中调试时重新渲染页面

javascript - Video.js - 使其能够响应不同尺寸

javascript - 在 jquery(或 javascript)中旋转,在页面上输入

html - 防止 <button> 在 IE 中点击时移动

ajax - 脚本 5 : Access is denied in IE9 for iframe on the same domain

css - 带有表格单元格父级和绝对定位伪元素的 IE 垂直居中错误