agauad
07-13-2006, 10:00 PM
Hello,
I'm trying to build a function that includes a javascript or php script into the web page by including a SCRIPT element into the HEAD element.
the code looks like this:
function includeScript(filePath){
var fileExt = filePath.substring(filePath.lastIndexOf("."),filePath.length);
var scriptType;
switch(fileExt){
case "js": scriptType = "text/javascript";
break;
case "php": scriptType = "text/php";
break;
}
var scrElement = document.createElement("script");
scrElement.setAttribute("type",scriptType);
srcElement.setAttribute("src",filePath);
document.documentElement.childNodes[0].appendChild(scrElement);
}
Do someone knows why the browser launchs an error telling that it is unable to open the window......
Thanks and regards
I'm trying to build a function that includes a javascript or php script into the web page by including a SCRIPT element into the HEAD element.
the code looks like this:
function includeScript(filePath){
var fileExt = filePath.substring(filePath.lastIndexOf("."),filePath.length);
var scriptType;
switch(fileExt){
case "js": scriptType = "text/javascript";
break;
case "php": scriptType = "text/php";
break;
}
var scrElement = document.createElement("script");
scrElement.setAttribute("type",scriptType);
srcElement.setAttribute("src",filePath);
document.documentElement.childNodes[0].appendChild(scrElement);
}
Do someone knows why the browser launchs an error telling that it is unable to open the window......
Thanks and regards