我想僅包含一個用於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