Created
January 5, 2014 20:23
-
-
Save pastleo/8273354 to your computer and use it in GitHub Desktop.
useful function when you need to import js without html...
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
function loadJS(url,loadFinished){ | |
if(typeof loadFinished != 'function') | |
loadFinished=function(){}; | |
rs_nav.message("JS from "+url+" start to load..."); | |
var JS = document.createElement('script'); | |
JS.setAttribute('src', url); | |
if (document.getElementsByTagName('head').item(0) == null) | |
document.getElementsByTagName('html').item(0).appendChild(document.createElement('head')); | |
JS.onload = function(){ | |
rs_nav.message("JS from "+url+" is loaded!"); | |
loadFinished(); | |
}; | |
JS = document.getElementsByTagName('head').item(0).appendChild(JS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment