JavaScript   发布时间:2022-04-16  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了JS使用cookie设置样式的方法大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了JS使用COokie设置样式的方法。分享给大家供大家参,具体如下:

{ var cookieEnd = document.cookie.indexOf(";",cookieStart); if (cookieStart == -1) { alert(-2); cookieEnd = document.cookie.length; } cookieValue = decodeURIComponent(document.cookie.subString(cookieStart + cookiename.length,cookieEnd)); } for (var i = 0; i < styleShow.length; i++) { if (cookieValue == styleShow[i]) { alert(styleShow[i]); return styleShow[i]; } } return styleShow[0]; },//生成cookie //name cookie名 //value 值 //expires 过期时间 //path 路径 setCookie: function (name,value,expires,path,domain,securE) { var cookieText = encodeURIComponent(Name) + "=" + encodeURIComponent(value) + ";"; if (expires instanceof DatE) { cookieText += "expires=" + expires.toGMTString(); } if (path) { cookieText += ";path=" + path; } if (domain) { cookieText += ";domain=" + domain; } if (securE) { cookieText += ";secure"; } document.cookie = cookieText; },//重置cookie unsetCookie: function (name,securE) { this.set(name,"",new Date(0),screen); } };

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》及《

希望本文所述对大家JavaScript程序设计有所帮助。

大佬总结

以上是大佬教程为你收集整理的JS使用cookie设置样式的方法全部内容,希望文章能够帮你解决JS使用cookie设置样式的方法所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。