I'm using <!--[if IE 8]><![endif]-->
for targeting IE8, but there's some JS that I want to load for all browsers EXCEPT IE8, what conditional comment should I use?
Edit: I wonder if this would work: <!--[if lte IE 8]><![endif]-->
Thanks
Conditional comments are conditional statements interpreted by Microsoft Internet Explorer versions 5 through 9 in HTML source code. They can be used to provide and hide code to and from these versions of Internet Explorer. Conditional comments are not supported in Internet Explorer 10 and 11.
Conditional comments are a simple Internet-Explorer-only feature that Microsoft added to IE5 Windows and later. (Mac IE doesn't support them.) They provide an easy way to detect that the visitor is using an IE browser (and which version they're using). You can then serve IE users different blocks of HTML as required.
Conditional comments, which are nothing more than simple HTML comments that IE (up to version 9) happens to take a peep at, are used to throw a chunk of HTML at these browsers and only these browsers. Other well behaved, top-of-the-class browsers will simply see them as unremarkable comments and move along.
--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content. Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.
there's some JS that I want to load for all browsers EXCEPT IE8, what conditional comment should I use?
For something to appear in ‘other browsers’ that don't support CCs, you need a downlevel-revealed conditional comment.
<!--[if !IE 8]><!-->
....
<!--<![endif]-->
(this is slightly different to Microsoft's official syntax which is not valid HTML.)
“All browsers except IE8” is an unusual requirement, are you sure that's what you want? What about future versions of IE?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With