PDA

View Full Version : Error on 'appendChild' to DIV



eldad87
05-11-2007, 12:17 PM
Hello,
I'm trying to use this gallery script (http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm),
I'm using Ajax to load new content into DIV,
Then I'm trying to load the gallery scripts files into this DIV also,
but when I'm trying to load 'scriptaculous.js?load=effects' the page refresh itself.

I'm using this function to load the files into the DIV:


var loadedobjects=""
function loadobcss(obj,file){
if (!document.getElementById)
return

var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("media", "screen");
fileref.setAttribute("href", file);
}

}
if (fileref!=""){
document.getElementById(obj.id).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}


i Hope someone know the answer