1,首先写入jsCookied
代码如下:
//浏览记录 写入JSCookied 开始
var img=$("#ProductImgurl").attr("jqimg");
var name=$("#ProductDetail_ctl00_LabelName").text();
var url=location.href;
var price=$("#ProductDetail_ctl00_LabelShopPrice").text();
var sellcount=$("#ProductDetail_ctl00_lblSaleNumber").text();
var hc=img+"|"+name+"|"+url+"|"+price+"|"+sellcount;
if($.cookie("history")!=null)
{
if($.cookie("history").indexOf(name)==-1)
{
$.cookie("history",hc+"*"+$.cookie("history"),{expires:8,domain:'.groupfly.com',path:"/"});
}
}
else
{
$.cookie("history",hc,{expires:8,domain:'.groupfly.com',path:"/"});
}
//浏览记录 写入JSCookied 结束
2,然后再读取Cookied
代码如下:
//读取cookied历史记录
$(function(){
var hc=$.cookie("history"); ¥/Uploads/'+splithtml[i].split("|")[3]+' ¥/Uploads/'+hc.split("|")[3]+' function clearcookied()
if(hc!=null)
{
if(hc.indexOf("*")!=-1)
{
var splithtml=hc.split("*");
var xhtml=new Array();
var hlength=splithtml.length;
if(parseInt(hlength)>4)
hlength=4;
for(var i=0;i
xhtml.push('/Uploads/'+splithtml[i].split("|")[1].substr(0, 17)+'');
xhtml.push('
xhtml.push('已销售/Uploads/'+splithtml[i].split("|")[4]+'笔再看看');
}
xhtml.push('清空记录');
$("#MyHistory").append(xhtml.join(""));
}
else{
var xhtml=new Array();
xhtml.push('/Uploads/'+hc.split("|")[1].substr(0, 17)+'');
xhtml.push('
xhtml.push('已销售/Uploads/'+hc.split("|")[4]+'笔再看看');
xhtml.push('清空记录');
$("#MyHistory").append(xhtml.join(""));
}
}
else
{
$("#MyHistory").append("
}
});
{
$.cookie('history',null,{expires:1,domain:'.nrqiang.com'});
$("#MyHistory").html("
}
$(function() {
$("img").each(function(){$(this).attr("src",$(this).attr("original"));});
});
script>