问题
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