我想仅包含一个用于IE8浏览器的JavaScript文件。例如:如何在meteor.js包中包含用于IE8浏览器的JavaScript文件?
<!--[if lt IE 9]>
<script src="js/ie/html5shiv.js"></script>
<![endif]-->
我使用我的流星包继package.js代码:
Package.onUse(function (api) {
api.versionsFrom("[email protected]");
api.use('jquery');
var path = Npm.require('path');
var asset_path = path.join('js);
// Surround following code in <!--[if lt IE 9]> and <![endif]--> tags somehow!!!!
api.addFiles(path.join(asset_path, 'ie', 'html5shiv.js'), 'client');
}
我知道,最终方案将包含所有js文件组合在一个js文件的缩小版本。在这种情况下,我想有代码的样子:
<!--[if lt IE 9]>
// Contents of html5shiv.js here!
<![endif]-->
有趣的解决方案!我在想如果这可以做到不污染Meteor.startup func。希望我的软件包能够开箱即用。也许我应该编辑html5shiv.js,并将其所有内容放在“”“if(!document.addEventListener){//html5shiv.js content here!}”“”中。你怎么看? – 2014-09-29 16:26:55
为什么不把'script'标签直接放在头部,在条件内? – Gigo 2015-12-03 23:57:54