Created by Jerry Wang, last modified on Sep 22, 2015
includeScript
createElement
<html>
<script>
function loadScript(url, callback){
var script = document.createElement ("script") ;
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" || script.readyState == "complete"){
script.onreadystatechange = null;
callback();
} // end of readyState
}; // end of onreadystatechange
} // end of IE
else { //Others
script.onload = function(){
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
loadScript("026_test.js", function(){
console.log("File is loaded!");
hello();
});
</script>
</html>
UI5 框架的use case: