将IE 8 Only JavaScript添加到Orchard CMS头元素

时间:2014-04-28 21:37:20

标签: javascript asp.net internet-explorer razor orchardcms

我想将Bootstrap推荐的填充程序添加到Orchard CMS head。通常,我会添加以下内容。

<!-- 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="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]-->

这是Orchard方式将{8}只添加到head的JavaScript吗?

  • 如果是,我们如何从Layout.cshtml视图向Orchard CMS head添加评论?
  • 如果不是,我们如何将仅限IE 8的JavaScript添加到Orchard CMS head

1 个答案:

答案 0 :(得分:4)

@Script()AtHead()UseContition()结合使用。

这是一种快速的Orchard方法,可以将仅用于IE 8的Bootstrap推荐的填充程序添加到Orchard CMS head

Script.Include("//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js")
    .AtHead()
    .UseCondition("lt ie 9");

Script.Include("//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js")
    .AtHead()
    .UseCondition("lt ie 9");

SO Post讨论@Script,此Orchard Issue提及UseCondition