<script language="javascript" src="" id="b2"></script>
<script language="javascript">
function request(id,url){
oScript = document.getElementById(id);
var head = document.getElementsByTagName("head").item(0);
if (oScript) {
head.removeChild(oScript);
}
oScript = document.createElement("script");
oScript.setAttribute("src", url);
oScript.setAttribute("id",id);
oScript.setAttribute("type","text/javascript");
oScript.setAttribute("language","javascript");
head.appendChild(oScript);
return oScript;
}
</script>
动态加载 javascript
本文介绍了一种使用JavaScript动态加载外部JS文件的方法。通过创建并操作script标签,可以按需加载不同功能模块,这对于实现模块化编程及优化页面加载性能非常有用。

被折叠的 条评论
为什么被折叠?



