<script language="javascript">
document.write("<script src=‘test.js‘><\/script>");
</script>
第二种、动态改变已有script的src属性
<script src=‘‘ id="s1"></script>
<script language="javascript">
s1.src="test.js"
</script>
第三种、动态创建script元素:
<script>
var oHead = document.getElementsByTagName(‘HEAD‘).item(0);
var oScript= document.createElement("script");
oScript.type = "text/javascript";
oScript.src="test.js";
oHead.appendChild( oScript);
</script>
时间: 2024-11-05 18:46:27