English 中文(简体)
Will IE9 support conditional comments?
原标题:

I thought I remembered reading somewhere that IE9 would not be supporting them, but now after searching I can t find any indication that this is true.

Is anyone aware of a definitive statement, either way, about whether Microsoft will be supporting conditional comments in IE9?

问题回答

The Platform Preview supports them, fire it up (or download it, then fire it up) and see this example - http://jsbin.com/axaju3:

<!--[if IE 9]>
    <p>You are using IE 9</p>
<![endif]-->

Tested in IE 9 Document Mode.

Straight from the horse s mouth, EricLaw from the IE team has confirmed in the comments below that CCs are still available in IE9.


A recent post on the IE blog shows that, as part of the effort to get consistent cross-browser HTML5 parsing, conditional comments will not work in IE10 s rendering engine:

<!--[if IE]>
This content is ignored in IE10 and other browsers.
In older versions of IE it renders as part of the page.
<![endif]-->

This is true as of Platform Preview 2 and the author suggests you should use feature detection as an alternative.

Internet Explorer 9 will be the last version to support conditional comments. With the release of Internet Explorer 10, Microsoft is turning over a new leaf. According to the MSDN article on Conditional Comments:

Support for conditional comments has been removed in Windows Internet Explorer 10 Release Preview standards and quirks modes for improved interoperability and compliance with HTML5. This means that Conditional Comments are now treated as regular comments, just like in other browsers. This change can impact pages written exclusively for Windows Internet Explorer or pages that use browser sniffing to alter their behavior in Internet Explorer.

While this will not affect the majority of sites online, there s a chance it may affect yours. If it does, please consider making use of the x-ua-compatible meta tag or header to instruct Internet Explorer to Emulate Internet Explorer 9 (the last version to support conditional comments):

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

Note that this will prevent you from having access to the newest features of the browser, like broader support for HTML5, and CSS3, as well as more JavaScript APIs.

The best solution is to ween yourself off of conditional comments. With Internet Explorer 10, Microsoft s browser will begin to operate much the same way other popular browsers do, requiring less attention to writing IE-specific code, as well as removing the need for conditional comments altogether.

Conditional Comments aren t the only thing to become obsolete in IE10. There s more.

I believe it will have to, otherwise a huge amount of sites will break all at once and it s not in the best Microsoft s interests to make that sort of start for IE9.

If there is going to be some sort of compatibility mode, then it is possible conditional comments will be supported in this mode but not in "pure IE9".

P.S. Just speculations.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签