【问题标题】:Why is Chrome ignoring IE conditional tag?为什么 Chrome 会忽略 IE 条件标签?
【发布时间】:2014-05-16 02:39:41
【问题描述】:

我正在使用自定义引导 wordpress 主题。

我的头是根据 Bootstrap 建议创建的

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<?php wp_head(); ?>
</head>

我可能误解了 IE 条件标记的意义​​,但我希望 IE hack 代码只能在 IE 中加载,但是所有这些脚本都存在于 Chrome 中。

我是否滥用了这个标签?是否有另一种推荐的方法来确保这些脚本只为比版本 9 更轻的 IE 浏览器加载?

我更喜欢让我的页面尽可能简洁,所以我不想为了安抚仍在使用 ie8 及以下版本的愚蠢的少数人而加载不必要的代码。

【问题讨论】:

    标签: wordpress twitter-bootstrap internet-explorer conditional


    【解决方案1】:

    --&gt; 结束评论。所以,这个评论的结尾:

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    

    也是对Chrome渲染引擎的注释部分的结尾。

    解决方案很简单:只需将评论标签移到 IE 条件之外。

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    

    【讨论】:

    • 你摇滚!谢谢你 :) 只是等着让我接受你的回答。
    猜你喜欢
    • 2018-08-10
    • 2012-12-11
    • 2018-05-13
    • 1970-01-01
    • 2010-09-25
    • 2021-10-20
    • 2022-07-14
    • 1970-01-01
    相关资源
    最近更新 更多