Pregunta

I would like to add the Bootstrap-recommended shims to the Orchard CMS head. Usually, I would add the following.

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

Is this the Orchard way to add IE 8 only JavaScript to the head?

  • If yes, how do we add comments to the Orchard CMS head from the Layout.cshtml view?
  • If no, how do we add IE 8 only JavaScript to the Orchard CMS head?
¿Fue útil?

Solución

Combine @Script() with AtHead() and UseContition().

This is a quick, Orchard way to add the Bootstrap-recommended shims, for IE 8 only, to the 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");

This SO Post discusses @Script and this Orchard Issue mentions the UseCondition.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top