用javaScript加载css、js
代码语言:javascript
复制
function addLink(url) {
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = url;
document.getElementsByTagName("head")[0].appendChild(link);
}
function addScript(url) {
var newscript = document.createElement('script');
newscript.setAttribute('type','text/javascript');
newscript.setAttribute('src',url);
var head = document.getElementsByTagName('head')[0];
head.appendChild(newscript);
}
addScript("js文件链接");
addLink("css文件的链接");