Copy Code code as follows:
<script type= "Text/javascript" >
function Addstyle (Stylepath) {
var container = document.getElementsByTagName ("head") [0];
var Addstyle = document.createelement ("link");
Addstyle.rel = "stylesheet";
Addstyle.type = "Text/css";
Addstyle.media = "screen";
Addstyle.href = Stylepath;
Container.appendchild (Addstyle);
}
Addstyle (' http://www.xxx.com/wintys/dynamic.css ');
</script>
JS writes the function, used to control the dynamic loading of JS files, that is, when the need to load the JS file, but also can load CSS files, so you can achieve the Web page skin, which I think this function is written well, seriously look at, their own in the perfect, or quite good.
Copy Code code as follows:
function $import (path,type,title) {
var s,i;
if (!type) type=path.substr (Path.lastindexof (".") +1);
if (type== "JS") {
var ss=document.getelementsbytagname ("script");
for (i=0;i<ss.length;i++) {
if (ss[i].src && ss[i].src.indexof (path)!=-1 | | ss[i].title==title) return SS[I];
}
S=document.createelement ("script");
S.type= "Text/javascript";
S.src=path;
if (title) S.title=title;
}
else if (type== "CSS") {
var ls=document.getelementsbytagname ("link");
for (i=0;i<ls.length;i++) {
if (ls[i].href && ls[i].href.indexof (path)!=-1 | | ls[i].title==title) return LS[I];
}
S=document.createelement ("link");
S.rel= "stylesheet";
S.type= "Text/css";
S.href=path;
if (title) S.title=title;
S.disabled=false;
}
else return;
var head=document.getelementsbytagname ("head") [0];
Head.appendchild (s);
return s;
}