IE 条件不适用于 .js 和 .css

IE condition not working for .js and .css

我使用此代码是为了仅针对 IE 浏览器加载 ie.css。但它不起作用,?我很困惑! 谁能帮帮我?

<html>
    <head>
      <title>Demo for IE</title>
      <!--[if IE]>
          <link rel="stylesheet" type="text/css" href="ie.css" />
      <![endif]-->
    </head>
    <body>
        <h1>Testing for IE</h1>
    </body>
</html>

IE10 和 IE11 不再支持条件注释。所以很可能,您正在使用这些版本之一

供您参考:

https://msdn.microsoft.com/en-us/library/ms537512.aspx

http://en.wikipedia.org/wiki/Conditional_comment

<!DOCTYPE html>
<html lang="en">
<head>
    <!--[if lt IE 9]>
 <link rel="stylesheet" type="text/css" href="ie.css" />
    <![endif]-->
</head>


<body>
</body>
</html>

这将在 IE9 以下的 IE 上应用 ie.css。您可以更改 IE 版本。