换皮肤功能-link
换肤功能
创建Css类,主要是对link元素操作
<link rel="stylesheet" type="text/css" media="all" href="styles/red.css" />
元素标签-link 属性标签-rel、type、media、href
var head = document.getElementsByTagName("head")[0];
this.Append = function(url){
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.media = "all";
link.href = url;
if (head) {
head.appendChild(link);
}
else {
document.documentElement.appendChild(link);
}
return link;
}
this.Remove = function (obj) {
if (typeof (obj) == "object" && obj.rel == "stylesheet") {
obj.rel = "NoCss";
if (head) head.removeChild(obj);
else document.documentElement.removeChild(obj);
return true;
}
else {
return false;
}
}