Created
June 15, 2012 03:27
-
-
Save learning/2934507 to your computer and use it in GitHub Desktop.
Load Script
This file contains 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
var loadScript = function(url, callback){ | |
var d = document, | |
script = d.createElement('script'); | |
script.type = 'text/javascript'; | |
if(script.readyState){ | |
script.onreadystatechange = function(){ | |
if(script.readyState == 'loaded' || script.readyState == 'complete'){ | |
script.onreadystatechange = null; | |
callback.call(this); | |
} | |
}; | |
}else{ | |
script.onload = function(){ | |
callback.call(this); | |
}; | |
} | |
script.src = url; | |
d.getElementsByTagName('head')[0].appendChild(script); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment