html条件语句hack在生活时将IE视为错误版本 [英] html conditional statement hack sees IE as wrong version when live

查看:109
本文介绍了html条件语句hack在生活时将IE视为错误版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Basically, I'm optimizing a website for the different versions of IE. I'm using IE9 (verified through the about page of IE).

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

Locally (with xampp) the website correctly detects that the browser is IE9 and loads the correct css code. However, when i put the code onto a text server, it sees the browser as IE7.

对于测试:

输出我用xmapp本地获取

Output I get locally with 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

输出我在测试服务器上:

Output I get on the test server:

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

有关问题的任何想法?

Any ideas on what the issue could be?

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

What I used to check versions

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


推荐答案

尝试在您的头部添加此元数据:

Try adding this meta in your head section:

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

此doctype:

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

这篇关于html条件语句hack在生活时将IE视为错误版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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