最近任务要求某个项目有多个主题,要求某个主题不出现广告
//cookie function setCookie(cname, cvalue, exdays) {//设置cookie方法 var d = new Date();//获取当前时间 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));//格式化为cookie识别的时间 var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + "; " + expires;//设置cookie } function getCookie(cname) {//获取cookie方法 var name = cname + "="; var ca = document.cookie.split(';');//将获得的cookie以"分号"为标识 将cookie保存到ca的数组中 for (var i = 0; i < ca.length; i++) { var c = ca[i].trim(); if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function checkCookie() { var theme = getCookie("theme_bazihehun"); if (theme == "30") { $("#publicFydNew").hide(); } } checkCookie()
附件参考:
https://www.cnblogs.com/zqifa/p/js-cookie-1.html
https://blog.csdn.net/minolk/article/details/80540750