百度了一下,借用了别人的setCookie,getCookie函数,采用cookie来存储一下即可,(Js脚本)
function setCookie(name, value, iDay) { var oDate=new Date(); oDate.setDate(oDate.getDate()+iDay); document.cookie=name+‘=‘+encodeURIComponent(value)+‘;expires=‘+oDate; } function getCookie(name) { var arr=document.cookie.split(‘; ‘); var i=0; for(i=0;i<arr.length;i++) { //arr2->[‘username‘, ‘abc‘] var arr2=arr[i].split(‘=‘); if(arr2[0]==name) { var getC = decodeURIComponent(arr2[1]); return getC; } } return ‘‘; } function removeCookie(name) { setCookie(name, ‘1‘, -1); }
时间: 2024-10-28 10:40:30