Return to Snippet

Revision: 17003
at August 20, 2009 12:48 by quickredfox


Initial Code
function loadScript(src, callback) {
    var scriptTag = document.createElement("scriptTag")
    scriptTag.type = "text/javascriptTag";
    if(scriptTag.readyState) {
        //IE
        scriptTag.onreadystatechange = function() {
            if (scriptTag.readyState == "loaded" ||
            scriptTag.readyState == "complete") {
                scriptTag.onreadystatechange = null;
                setTimeout(function(){scriptTag.parentNode.removeChild(scriptTag)},1)
                callback();
            }
        };
    }else{
        //Others
        scriptTag.onload = function() {
            setTimeout(function(){scriptTag.parentNode.removeChild(scriptTag)},1)           
            callback();
        };
    }
    scriptTag.src = src;
    document.getElementsByTagName("head")[0].appendChild(scriptTag);
}

Initial URL

                                

Initial Description

                                

Initial Title
Javascript Simple Script Loader

Initial Tags
javascript, script, simple

Initial Language
JavaScript