先必須要引用一個js jquery.cookie.js
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=$""">Product"""> 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
');
xhtml.push ('
¥' splithtml[i].split("|") [3] '
');
xhtml.push('
已售出' splithtml[i].split("| ")[4] '筆再看看
');
}
xhtml.push('
' );
$("#MyHistory").append(xhtml.join(""));
}
else{
var xhtml=new Array();
xhtml.push ('
');
xhtml.push('
¥' hc.split("|")[3] '
');
xhtml.push('
');
xhtml.push('
清空記錄 div>');
$("#MyHistory").append(xhtml.join(""));
}
}
else
{
$("# MyHistory").append("
暫無瀏覽記錄");
}
});
function clearcookied()
{
$. cookie('history',null,{expires:1,domain:'.nrqiang.com'});
$("#MyHistory").html("
暫無瀏覽記錄" );
}
$(function() {
$("img").each(function(){$(this).attr("src",$(this).attr(" original"));});
});