问题
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]> <html> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
The above code, does not seem to work in the least bit. The only IE version that my website(The Randy) seems to work in is IE9. I thought it was working because of the conditional statements I've input above, but it works in IE9 without those statements as well. If I look at it in IE8 and IE7 I get a broken looking website. Any help would be most appreciated.
回答1:
Conditional comments are not supported in IE 10 and are a bad idea anyway, especially since standards have been set.
You should ALWAYS use feature detection instead of browser detection.
EDIT: Reading the Console helps too:
HTML1513: Extra "
<html>
" tag found. Only one "<html>
" tag should exist per document.
therandy.tk, line 9 character 20HTML1503: Unexpected start tag.
therandy.tk, line 12 character 1HTML1512: Unmatched end tag.
therandy.tk, line 245 character 208HTML1514: Extra "
<body>
" tag found. Only one "<body>
" tag should exist per document.
therandy.tk, line 247 character 1HTML1519: Invalid nesting. An "
<a>
" tag should not be placed within another "<a>
".
therandy.tk, line 364 character 97
回答2:
In your markup, you have a <script>
tag before your <html>
tag opens. That's not valid code, and IE probably doesn't like this. Move that <script>
so that it's in your document <head>
instead.
来源:https://stackoverflow.com/questions/14947733/if-ie-statements-not-working