document.createElement(“脚本”)同步
.js
<script type="text/javascript"> var head = document.getElementsByTagName('head').item(0); var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', 'http://mysite/my.js'); head.appendChild(script); myFunction(); // Fails because it hasn't loaded from my.js yet. window.onload = function() { // Works most of the time but not all of the time. // Especially if my.js injects another script that contains myFunction(). myFunction(); };</script>
// Include() is a custom function to import js.Include('my1.js');Include('my2.js');myFunc1('blarg');myFunc2('bleet');
人到中年有点甜
相关分类