A: 

I found the solution. The problem was that i create the element not on the same window object. To fix it i add the line: parent.document.CreateElement instead of: document.CreateElement

The fixed code is:


function LoadJSCSSFile(filePath,fileType,parentBOO){
    //-
    var fileRef;            // Get the file reference
    //-
    //Set external JavaScript/CSS file
    switch(fileType){
        case "js":
            if(parentBOO){
                fileRef = parent.document.createElement('script');
            }else{
                fileRef = document.createElement('script');
            }
            fileRef.setAttribute("type","text/javascript");
            fileRef.setAttribute("src", filePath);
            break;
        case "css":
            if(parentBOO){
                fileRef = parent.document.createElement("link");
            }else{
                fileRef = document.createElement("link");
            }
            fileRef.setAttribute("rel", "stylesheet");
            fileRef.setAttribute("type", "text/css");
            fileRef.setAttribute("href", filePath);
            break;
        default:
            return;
            break;
    }

    //Load the file
    if(parentBOO){
        parent.document.getElementsByTagName("head")[0].appendChild(fileRef);
    }else{
        document.getElementsByTagName("head")[0].appendChild(fileRef);
    }
}

Roy Shoa