web css實現(xiàn)整站樣式互相切換
直接貼代碼
//取元素 用兩個$是為了不與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);
//}
});
相關文章
微信小程序MUI導航欄透明漸變功能示例(通過改變rgba的a值實現(xiàn))
這篇文章主要介紹了微信小程序MUI導航欄透明漸變功能,結合實例形式分析了通過改變rgba的a值實現(xiàn)透明度漸變功能的相關操作技巧,需要的朋友可以參考下2019-01-01微信小程序 JS動態(tài)修改樣式的實現(xiàn)方法
這篇文章主要給大家介紹了關于微信小程序JS動態(tài)修改樣式的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2018-12-12以JSON形式將JS中Array對象數(shù)組傳至后臺的方法
業(yè)務是需要將前臺jQuery easyUI DataGrid列表中所選的若干行的數(shù)據(jù)傳到后臺進行update操作,具體的實現(xiàn)如下,感興趣的朋友可以參考下2014-01-01微信小程序動態(tài)評分展示/五角星展示/半顆星展示/自定義長度展示功能的實現(xiàn)
這篇文章主要介紹了微信小程序動態(tài)評分展示/五角星展示/半顆星展示/自定義長度展示的實現(xiàn),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-07-07由淺入深講解Javascript繼承機制與simple-inheritance源碼分析
Javascript語言對繼承實現(xiàn)的并不好,需要工程師自己去實現(xiàn)一套完整的繼承機制。下面我們由淺入深的系統(tǒng)掌握使用javascript繼承的技巧,對javascript繼承相關知識感興趣的朋友一起看看吧2015-12-12