Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help here

Status
Not open for further replies.

jweiss33

Programmer
Jun 9, 2008
5
US
Hi, I need a little help here. What I have here is a function that calls and loads javascripts/css dynamically. The problem is it is set to not load it again if the files have been loaded once already. I need the files to load dynamically everytime. When I click on the button it calls the external javascript great and everything works. The only problem is if I click on it again everything breaks. If anyone can help me remove the portion that checks to see if it has already been loaded that would be great. I need it to load everytime it is called on. Thank You in advance.

Here is the function

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments
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("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

Thank You,
JW
 
Hi, Yes. I have tried removing that and still the same thing is happening. I have also removed a few other lines and still the same issue. Any help is appreciated .


Thank You,
JW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top