标签:span 时间 col code gettime fun color document tst
前端中使用cookie:
存储:document.cookie="usrename=XSS";
function setCookie(name,value,hours){ var d = new Date(); d.setTime(d.getTime() + hours * 3600 * 1000); document.cookie = name + ‘=‘ + value + ‘; expires=‘ + d.toGMTString(); }
查看:
function getCookie(name){ var arr = document.cookie.split(‘; ‘); for(var i = 0; i < arr.length; i++){ var temp = arr[i].split(‘=‘); if(temp[0] == name){ return temp[1]; } } return ‘‘; }
删除:设置过期时间为过去即可。
function removeCookie(name){ var d = new Date(); d.setTime(d.getTime() - 10000); document.cookie = name + ‘=1; expires=‘ + d.toGMTString(); }
标签:span 时间 col code gettime fun color document tst
原文地址:https://www.cnblogs.com/pecool/p/10549488.html