我想动态地在网页中包含一个脚本标签但是我无法控制它的src所以src ="source.js"可能看起来像这样.
document.write('<script type="text/javascript">')
document.write('alert("hello world")')
document.write('</script>')
document.write('<p>goodbye world</p>')
Run Code Online (Sandbox Code Playgroud)
现在通常放
<script type="text/javascript" src="source.js"></script>
Run Code Online (Sandbox Code Playgroud)
在头部工作正常但是有没有其他方法我可以使用像innerHTML这样的东西动态添加source.js?