为什么[if ...]条件在我的html中不起作用?

And*_*man 0 html javascript html5

我在Google Chrome 70.0.3538.67和Internet Explorer 11.55.17763.0中打开此html文件:

<!doctype html>
<html lang="ru">
<head>
    <meta charset="utf-8"/>
    <!-- saved from url=(0014)about:internet -->
    <title>Sandbox</title>
    <link href="index.css" rel="stylesheet"/>
    <script>
        console.log('Hello all!')
    </script>
    <!--[if gt IE 9]>
    <script>
        console.log('Hello from IE newer then 9!')
    </script>
    <![endif]-->
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我期待两种浏览器的输出:

大家好!
你好,IE更新,然后9!

但我只得到:

大家好!

为什么会这样?

Dan*_*eck 8

条件注释是Internet Explorer专有的,在其他浏览器中从不支持.在版本10中从IE中删除了支持.

此技术已过时,不再需要依赖(除非您明确针对IE版本5到9).