http://zhenggm.iteye.com/blog/680600
//js Map var JSHash = { index: [{url:"http://xxxx.js", version: "1.0"}], edit: [{url:"http://xxxx.js", version: "2.0"}] }2. 在页面中通过js map的key来动态加载js文件;
<script src=config.js></script> <script> loadJS("edit"); </script> //根据传入的key,动态生成js加载语句 function loadJS(sKey) { var node = JSHash[sKey]; for(var i =0;i < node.length; i ++) { document.writeln(‘<script src="‘+node[i].url+‘?version=‘+node[i].version+‘"><\/script>‘); } } //--> </script>
原文:http://www.cnblogs.com/freeliver54/p/5126592.html