Created
December 5, 2013 10:59
-
-
Save simplelife7/7803521 to your computer and use it in GitHub Desktop.
【JS】原生动态插入脚本函数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function includeScriprt(url,fnback){ | |
var script = document.createElement("script"); | |
script.type="text/javascript"; | |
script.src = url; | |
document.getElementsByTagName("body")[0].appendChild(script); | |
function done(){ | |
fnback(); | |
} | |
script.onload = script.onreadystatechange = function(){ script.readyState ? script.readyState.toLowerCase() == 'loaded' && done() : done() }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment