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

首頁(yè) > 編程 > JavaScript > 正文

web css實(shí)現(xiàn)整站樣式互相切換

2019-11-20 21:49:55
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

直接貼代碼

復(fù)制代碼 代碼如下:

//取元素 用兩個(gè)$是為了不與jquery沖突
function $$(s) {
    return document.getElementById(s);
}
function setblue() {
    //先寫cookie
    //writeCookie("ISCSSSTYLE", "css/CRM_blue.css", 365, true);
    //設(shè)置新的css文件
    $$("maincss").href = "css/CRM_blue.css";
    //取主框架頁(yè),并重新設(shè)置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);
    //設(shè)置新的css文件
    $$('maincss').href = "css/CRM.css";
    //取主框架頁(yè),并重新設(shè)置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);
    //設(shè)置新的css文件
    $$('maincss').href = "css/CRM_gray.css";
    //取主框架頁(yè),并重新設(shè)置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";
    //設(shè)置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);
    //}
});

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 祥云县| 施甸县| 和顺县| 宁晋县| 玉树县| 阿拉尔市| 伊宁县| 郁南县| 正阳县| 铜陵市| 贵溪市| 江西省| 天峨县| 唐山市| 黄骅市| 松潘县| 同心县| 长子县| 依兰县| 金阳县| 长宁区| 浑源县| 东丽区| 广饶县| 濉溪县| 定兴县| 三门峡市| 大丰市| 盐边县| 乡城县| 奉新县| 邵阳市| 潼关县| 玉环县| 绍兴县| 小金县| 林西县| 军事| 石狮市| 江陵县| 彭水|