I don't think you want to. If you're loading javascript with loadobjs, you would eventually get a situation where you have tons of possibly conflicting javascript scripts in the head of the page, if you're loading css files, a similar thing could happen.
And I've noticed because I actually tried this once that at least in the case of stylesheets, IE has a limit as to the number of stylesheets one can jam into the page via appending them to the head. But that was with on page stylesheets, as opposed to stylesheet <link> tags.
So you can try it. In the loadobjs function, comment out this line as shown:
Code:
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
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
}
}
}
But since you're using jQuery, I'd be inclined to scrap both DD AJAX scripts and instead use jQuery AJAX functions. At the very least, use something like so for loading in external sheets (untested - modeled after the solution I used):
Code:
function addOrReplaceSheet(href){
var $ = jQuery, title="addedorreplaced", oldSheet = $('link[title="' + title + '"]'),
newSheet = $('<link rel="stylesheet" type="text/css">').attr({href: href, title: title});
if(oldSheet.size()){
oldSheet.last().replaceWith(newSheet);
} else {
newSheet.appendTo('head');
}
}
Bookmarks