html conditional statement hack sees IE as wrong version when live

你说的曾经没有我的故事 提交于 2019-12-12 00:28:53

问题


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

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.

For tests:

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?

Edit: 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]-->

回答1:


Try adding this meta in your head section:

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

And this doctype:

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


来源:https://stackoverflow.com/questions/8187346/html-conditional-statement-hack-sees-ie-as-wrong-version-when-live

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