国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

web css實現整站樣式互相切換

2024-05-06 15:53:46
字體:
來源:轉載
供稿:網友
css輕松實現整站樣式互相切換。需要的朋友可以過來參考下,希望對大家有所幫助

直接貼代碼

復制代碼 代碼如下:


//取元素 用兩個$是為了不與jquery沖突
function $$(s) {
    return document.getElementById(s);
}
function setblue() {
    //先寫cookie
    //writeCookie("ISCSSSTYLE", "css/CRM_blue.css", 365, true);
    //設置新的css文件
    $$("maincss").href = "css/CRM_blue.css";
    //取主框架頁,并重新設置css文件
    //var childobj = window.parent.document.getElementById("ManagerMain").contentWindow;
    //childobj.document.getElementById("maincss").href = "css/CRM_blue.css";
}
function setgreen() {
    //先寫cookie
    //writeCookie("ISCSSSTYLE", "css/CRM.css", 365, true);
    //設置新的css文件
    $$('maincss').href = "css/CRM.css";
    //取主框架頁,并重新設置css文件
    //var childobj = window.parent.document.getElementById("ManagerMain").contentWindow;
    //childobj.document.getElementById("maincss").href = "css/CRM.css";
}
function setgray() {
    //先寫cookie
    //writeCookie("ISCSSSTYLE", "css/CRM_gray.css", 365, true);
    //設置新的css文件
    $$('maincss').href = "css/CRM_gray.css";
    //取主框架頁,并重新設置css文件
    //var childobj = window.parent.document.getElementById("ManagerMain").contentWindow;
    //childobj.document.getElementById("maincss").href = "css/CRM_gray.css";
}


function setActiveStyleSheet(title) {
    //    var i, a, main; 
    //    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
    //    { 
    //        if(a.getAttribute("rel").indexOf("style")!= -1 && a.getAttribute("title")) 
    //        { 
    //            a.disabled = true; 
    //            if(a.getAttribute("title") == title) 
    //            a.disabled = false; 
    //        }
    //    }
    //$$("maincss").attr("href", "css/CRM_blue.css");
    //$$('maincss').href = "css/CRM_blue.css";
    //設置css的文件
    $$('maincss').href = title;
}
function getActiveStyleSheet() {
    //    var i, a; 
    //    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
    //    { 
    //        if(a.getAttribute("rel").indexOf("style")!= -1 && 
    //         a.getAttribute("title") && !a.disabled) 
    //            return a.getAttribute("title"); 
    //    }
    //    return null;
    var cssfile = $$('maincss').href;
    //alert(cssfile);
    return cssfile;
}
function getPreferredStyleSheet() {
    //    var i, a; 
    //    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
    //    { 
    //        if(a.getAttribute("rel").indexOf("style") != -1 
    //            && a.getAttribute("rel").indexOf("alt") == -1 
    //            && a.getAttribute("title")) 
    //            return a.getAttribute("title"); 
    //    }
    //    return null;
    var cssfile = $$('maincss').href;
    //alert(cssfile);
    return cssfile;
}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else
        expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";


}
function writeCookie(name, value, hours, escp) {
    var expire = "";
    if (hours != null) {
        expire = new Date((new Date()).getTime() + hours * 3600000);
        expire = "; expires=" + expire.toGMTString();
    }
    if (escp == "True") {
        document.cookie = name + "=" + value + expire;
    } else {
        document.cookie = name + "=" + escape(value) + expire;
    }
}


function readCookie(name) {
    var nameEQ = name + "=";


    var ca = document.cookie.split(';');


    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];


        while (c.charAt(0) == ' ')
            c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0)
            return c.substring(nameEQ.length, c.length);
    }
    return null;
}
$(document).ready(function() {


    //var title = readCookie("ISCSSSTYLE");
    //var title = "css/CRM_blue.css";


    //if (title != null && title != "undefined") {
    //    setActiveStyleSheet(title);
    //}
});

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 德惠市| 松原市| 和田县| 崇州市| 台山市| 镇雄县| 勐海县| 东源县| 翁源县| 德保县| 海伦市| 宜章县| 永新县| 易门县| 河津市| 永丰县| 家居| 仙居县| 宜兴市| 丰城市| 巩留县| 盐池县| 桐梓县| 定南县| 托克托县| 商南县| 武功县| 当阳市| 吉安县| 友谊县| 建始县| 广南县| 会同县| 新建县| 扬州市| 巴林右旗| 修文县| 苗栗县| 招远市| 楚雄市| 瑞丽市|