首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >html条件语句黑客在活动时将IE视为错误版本

html条件语句黑客在活动时将IE视为错误版本
EN

Stack Overflow用户
提问于 2011-11-19 02:35:59
回答 1查看 712关注 0票数 0

基本上,我正在为IE的不同版本优化一个网站。我使用的是IE9 (通过IE的about页面验证)。

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

对于测试:

使用xmapp在本地获得的输出

代码语言:javascript
复制
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

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

代码语言:javascript
复制
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

有没有关于这个问题的想法?

编辑:我用来检查版本的东西

代码语言:javascript
复制
<!--[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]-->
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-19 02:53:03

尝试在head部分中添加此meta:

代码语言:javascript
复制
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>

和这个doctype:

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8187346

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档