网页换肤 //写入客户端Cookie function writeCookie(csspath) { var today = new Date(); var expires = new Date(); expires.setTime(today.getTime() + 1000 * 60 * 60 * 24 * 30); //有效期为30天 var str = "cssPath=" + csspath + ";expires=" + expires.toGMTString() + ";"; document.cookie = str; } //读取Cookie function readCookie(cookieName) { var search = cookieName + "="; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) { end = document.cookie.length; return unescape(document.cookie.substring(offset, end)); } } } } function ifCookie() { if (readCookie("cssPath") == undefined) { writeCookie("orange.css"); } document.getElementById("myCss").href = readCookie("cssPath"); } function change(type) { if (type == "orange") { document.getElementById("myCss").href = "orange.css"; writeCookie("orange.css"); } if (type == "gray") { document.getElementById("myCss").href = "gray.css"; writeCookie("gray.css"); } }
查看更多关于HTML/CSS网页换肤(二)_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did113972