Thanks a bunch this works great it is almost exactly what I am looking for!
I slightly modified the code to work with a function to add the relevant tags to the head section of the parent page, all I really need now to make it perfect is a way to include ALL script and link paths instead of just one of each!
The code I have now;
Code:
var loadedobjs= '';
jQuery(function($){
var re = [/[^"]+\.css[^"]*/, /[^"]+\.js[^"]*/];
function process(d){
var r1, r2;
r1 = (r1 = re[0].exec(d))? r1[0] : "";
r2 = (r2 = re[1].exec(d))? r2[0] : "";
loadobjs(r1, r2);
}
$.get('test.htm', process);
});
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjs.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)
loadedobjs+=file+" " //Remember this object as being already added to page
}
}
}
Thanks again it really helps!
Bookmarks