cookie 历史记录
程序员文章站
2022-04-05 10:19:01
...
//通用自动加载方法
if (document.all){ //ie
window.attachEvent('onload',readCookie);
} else{ //ff
window.addEventListener('load',readCookie,false);
}
//单击相应操作时的onclick方法
function setCookie(name, value){//name为key,key要唯一,value就是相应的值
value = encodeURI(value);//解决中文乱码
var date = new Date();
date.setTime(date.getTime()-1);//设置删除相应的
var broken_Cookie =document.cookie.split(";");
if(broken_Cookie.length > 10) {
var kuku = ""+broken_Cookie[0].split("=")[0]+"="+value+";expires="+date.toGMTString();+"";
document.cookie =kuku;
}
var Cookie = ""+name+"="+value+"";
document.cookie =Cookie;
}
//显示cookie为自动加载方法
function readCookie(){
var historyHereJob = document.getElementById("historyHereJob");
var Cookie = document.cookie;
var broken_Cookie =Cookie.split(";");
for(var i = 0; i < broken_Cookie.length; i++) {
var content = broken_Cookie[i];
var index = content.indexOf("hereJob");
if(index == 0 || index == 1) {
var li = document.createElement("li");
var text = content.split("=")[1];
text = decodeURI(text);
var index = content.split("=")[0];
li.innerHTML = "<span><a href='/HereB2B/app/job/jobshow/"+index.split('b')[1]+".htm' title='"+text+"'>"+text.substr(0,17)+"</a></span>";
historyHereJob.appendChild(li);
}
}
}
alert出来的东西
hereDeploy118=%E4%B8%AD%E5%9B%BD%E5%AE%81%E6%B3%A2%E7%89%B9%E8%AE%B8%E7%BB%8F%E8%90%A5%E5%8A%A0%E7%9B%9F%E8%BF%9E%E9%94%81%E5%B1%951; hereDeploy273=%E4%B8%AD%E5%9B%BD%E5%AE%81%E6%B3%A2%E7%89%B9%E8%AE%B8%E7%BB%8F%E8%90%A5%E5%8A%A0%E7%9B%9F%E8%BF%9E%E9%94%81%E5%B1%9513; JSESSIONID=D2D43F021F23CC650AC51E68D55730C9
上一篇: Elasticsearch 的学习
下一篇: zookeeper集群部署