How to write conditional comment for non IE browsers?

后端 未结 3 1165
小鲜肉
小鲜肉 2020-12-15 20:30

I don\'t want to use a couple of javascript plugins for IE 6/7. But I want to use them for all other browsers.

How can I do it? Is there any way I can do it?

3条回答
  •  轮回少年
    2020-12-15 20:49

    Your question would be better phrased as "Using conditional comments to exclude content from IE browsers" ;-)

    Although CCs are most often used to provide additional content for IE, there is a variant that allows you to prevent IE from seeing content. With their usual arrogance, MS chose to call this "downlevel-revealed conditional comments" (because all other browsers are worse than IE in their world).

    Something like

    You are not using Internet Explorer.

    should be all you need.

    Note that describing this as a "Conditional Comment" is another example of MS's strange use of words to mean exactly what they choose them to mean rather than what everybody else means: the above works because it isn't actually a comment, so all browsers other than IE just assume you made a hideous mistake in your HTML and carry on parsing the content within.

    This also means it will probably fail badly in XHTML served with the application/xhtml+xml content type, but that's another story.

提交回复
热议问题