如何在js文件中动态加载另一个js文件?

JavaScript013

如何在js文件中动态加载另一个js文件?,第1张

1、直接document.write\x0d\x0a\x0d\x0adocument.write("")\x0d\x0a\x0d\x0a\x0d\x0a2、动态改变已有script的src属性\x0d\x0a

用document.write方法来实现。

在js文件中动态加载另一个js文件代码及注释步骤:

<html>

<body>

<script type="text/javascript">

document.write("<script src='要引用js'><\/script>")

</script>

<p>write方法的使用</p>

</body>

</html>

定义和用法

write() 方法可向文档写入 HTML 表达式或 JavaScript 代码。

语法

document.write(exp1,exp2,exp3,....)