简体   繁体   English

带流星的IE的条件包含js / css文件

[英]Conditional include js/css files for IE with meteor

In pure html it is common to use conditional includes like: 在纯html中,通常使用条件包含,例如:

<!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <script src="js/ltie9.js"></script>
<![endif]-->

My ltie9.js is pretty simple 我的ltie9.js非常简单

$(document).ready(function(){
    $("#ltie9").modal('show');
});

The ltie9.js is wrapped by meteor into: ltie9.js被流星包裹到:

<script type="text/javascript" src="/client/js/ltie9.js?dbe4ceed5fdf7ec4fd714612d501c94e5c19c04b"></script>

Wrapped as it looks now: 包装如下:

(function(){$(document).ready(function(){
    $("#ltie9").modal('show');
});
})();

Seems that conditional comment doesn't work as the modal occurs even if I use Chrome. 即使使用Chrome,似乎也会出现条件注释,因为条件模式不会发生。 How to fix that conditional statement - should I check the browser vendor and version via js? 如何修正该条件语句-我应该通过js检查浏览器供应商和版本吗? Sounds like a very heavy solution. 听起来是很沉重的解决方案。

Any .js files in /client will simply be included in your codebase - you should not try to included them manually in the head. / client中的任何.js文件都将仅包含在您的代码库中-您不应尝试将它们手动包含在头中。

To do what you're looking to do, keep the conditional comment but place the JS file in the /public folder where they will be treated as static content (and not part of your application code). 要执行您想做的事情,请保留条件注释,但将JS文件放在/ public文件夹中,在该文件夹中,它们将被视为静态内容(而不是应用程序代码的一部分)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM