栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

使用HTML CSS实现网页换肤效果(二)

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用HTML CSS实现网页换肤效果(二)

废话不多说了,直接给大家贴html代码了,具体代码如下所示:
XML/HTML Code复制内容到剪贴板
  1.     
  2. 网页换肤    
  3.     
  4.     
  5.     
  6. //写入客户端cookie    
  7. function writecookie(csspath) {    
  8. var today = new Date();    
  9. var expires = new Date();    
  10. expires.setTime(today.getTime() + 1000 * 60 * 60 * 24 * 30); //有效期为30天    
  11. var str = "cssPath=" + csspath + ";expires=" + expires.toGMTString()    
  12. + ";";    
  13. document.cookie = str;    
  14. }    
  15. //读取cookie    
  16. function readcookie(cookieName) {    
  17. var search = cookieName + "=";    
  18. if (document.cookie.length > 0) {    
  19. offset = document.cookie.indexOf(search);    
  20. if (offset != -1) {    
  21. offset += search.length;    
  22. end = document.cookie.indexOf(";", offset);    
  23. if (end == -1) {    
  24. end = document.cookie.length;    
  25. return unescape(document.cookie.substring(offset, end));    
  26. }    
  27. }    
  28. }    
  29. }    
  30. function ifcookie() {    
  31. if (readcookie("cssPath") == undefined) {    
  32. writecookie("orange.css");    
  33. }    
  34. document.getElementById("myCss").href = readcookie("cssPath");    
  35. }    
  36. function change(type) {    
  37. if (type == "orange") {    
  38. document.getElementById("myCss").href = "orange.css";    
  39. writecookie("orange.css");    
  40. }    
  41. if (type == "gray") {    
  42. document.getElementById("myCss").href = "gray.css";    
  43. writecookie("gray.css");    
  44. }    
  45. }    
  46.     
  47.   

通过以上代码就可以简单实现使用HTML CSS实现网页换肤效果,希望本读代码对大家有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/216099.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号