/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }
URL: http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/