数码资讯
cookie最近的浏览记录(中国逃避转码)的具体实现
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
{ Javascript }
复制代码代码如下所示:
* pro_id:产品ID
* brand_name:品牌
* pro_name:产品ID
*价格:价格
*目录:模型
*图片:图片
* file_name:文件名
* /
无功addhistory =功能(pro_id,brand_name,pro_name、价格、目录、图片、file_name){
stringcookie = getcookie('history);
无功stringhistory = != stringcookiestringcookie:{史:{ } };
var json =新的JSON(stringhistory);
无功pro_ids =;
jquery.each(JSON { 'history},功能(我,Val){
pro_ids + = { } {我'history JSON的pro_id + }。
});
如果(jQuery.trim(pro_id)= =| | pro_ids.indexof(pro_id)= = 1){
var ={ pro_id:+ pro_id +brand_name:+ brand_name +pro_name:
JSON { 'history}。推(E); / /添加新记录
setcookie('history ',json.tostring()(),30);
}
}
显示/记录
displayhistory =函数(){ var
无功p_ele = document.getelementbyid('history);
而(p_ele。firstChild){
p_ele.removechild(p_ele。第一个孩子);
}
无功historyjson = getcookie('history);
var json =新的JSON(historyjson);
无功displaynum = 6;
对(我= JSON { 'history}。length-1;我> = 0;我--){
AddLi(JSON { } { } {我'history'pro_id},{ } {我的JSON 'history } { 'brand_name},{ } {我的JSON 'history } { 'pro_name},{ } {我的JSON 'history } { 'price},{ } {我的JSON 'history } { 'catalog},{ } {我的JSON 'history } { 'img},{ } {我的JSON 'history } { 'file_name},历史)。
displaynum --;
如果(displaynum = = 0){ break;}
}
}
添加一个cookie
无功addli =功能(pro_id,brand_name,pro_name、价格、目录、图片、file_name,PID){
创建一个document.createelement(A);
VaR href = / /+ file_name prodetail;
a.setattribute('href,href);
a.setattribute(目标
jQuery()。Html(+ unescape(brand_name + pro_name +目录)++ unescape(价格)+ );
VaR李= document.createelement(李的);
li.appendchild(一);
jQuery(李),AppendTo(+ PID # );
}
添加 cookie
无功setcookie =功能(c_name,价值,expiredays)
{
无功exdate =新的日期()
exdate.setdate(exdate.getdate()+ expiredays)
cookieval = c_name +=+逃跑(价值)+((expiredays = = null):;路径= /;到期=+ exdate.togmtstring());
饼干= cookieval文件;
}
获取cookie
功能getcookie(c_name)
{
如果(文档,长度> 0)
{
c_start = document.cookie.indexof(c_name +=)
如果(c_start!= 1)
{
c_start = c_start + c_name长度+ 1。
c_end = document.cookie.indexof(;
如果(c_end = = 1)c_end = document.cookie.length
返回unescape(document.cookie.substring(c_start,c_end))
}
}
返回
}
清除cookie
函数的DeleteCookie(){
setcookie('history、{史:{ } }
}
json.js
{ Javascript }
复制代码代码如下所示:
var json =功能(sjson){
this.objtype =(typeof sjson);
如果(这。objtype = = = = sjson 'String'){
sjson ={ } { }的历史;
}
this.self = { };
函数(s,o){
对于(var I o){
o.hasownproperty(我)(S {我} = O {我},{我} = O s.self {我})
};})(,(,objtype = = 'String')评价(0,+ sjson):sjson);
}
json.prototype = { {
说明:函数(){
返回this.getstring();
},
值:函数(){
返回this.getstring();
},
getString:函数(){
var;
(函数(o){)
var = null;
SA.push({);
对于(var I o){
如果(o.hasownproperty(我)我!= 'prototype){
OO = { };
如果(OO是数组){
SA.push(我+:{);
对于(在OO中的VaR B){
如果(oo.hasownproperty(B)B!= 'prototype){
SA.push(OO {b} + ',');
如果(typeof OO {黑} = = 'object)arguments.callee(OO {黑});
}
}
SA.push(},);
继续;
其他{ }
SA.push(我+:+对象+、);
}
如果(typeof面向对象= = 'object)arguments.callee(OO);
}
}
SA.push(},);
})(这个,自我);
返回sa.slice(0)。加入('')。更换( / {对象 }, / IG,更换(' ') / } / g,})(。取代 / } / g,})。片(0、1);
},
推:功能(SNAME,价值){
这名自{ } =价值;
这名} = {价值;
}
}
添加一个cookie
复制代码代码如下所示:
addhistory(
复制代码代码如下所示:
* pro_id:产品ID
* brand_name:品牌
* pro_name:产品ID
*价格:价格
*目录:模型
*图片:图片
* file_name:文件名
* /
无功addhistory =功能(pro_id,brand_name,pro_name、价格、目录、图片、file_name){
stringcookie = getcookie('history);
无功stringhistory = != stringcookiestringcookie:{史:{ } };
var json =新的JSON(stringhistory);
无功pro_ids =;
jquery.each(JSON { 'history},功能(我,Val){
pro_ids + = { } {我'history JSON的pro_id + }。
});
如果(jQuery.trim(pro_id)= =| | pro_ids.indexof(pro_id)= = 1){
var ={ pro_id:+ pro_id +brand_name:+ brand_name +pro_name:
JSON { 'history}。推(E); / /添加新记录
setcookie('history ',json.tostring()(),30);
}
}
显示/记录
displayhistory =函数(){ var
无功p_ele = document.getelementbyid('history);
而(p_ele。firstChild){
p_ele.removechild(p_ele。第一个孩子);
}
无功historyjson = getcookie('history);
var json =新的JSON(historyjson);
无功displaynum = 6;
对(我= JSON { 'history}。length-1;我> = 0;我--){
AddLi(JSON { } { } {我'history'pro_id},{ } {我的JSON 'history } { 'brand_name},{ } {我的JSON 'history } { 'pro_name},{ } {我的JSON 'history } { 'price},{ } {我的JSON 'history } { 'catalog},{ } {我的JSON 'history } { 'img},{ } {我的JSON 'history } { 'file_name},历史)。
displaynum --;
如果(displaynum = = 0){ break;}
}
}
添加一个cookie
无功addli =功能(pro_id,brand_name,pro_name、价格、目录、图片、file_name,PID){
创建一个document.createelement(A);
VaR href = / /+ file_name prodetail;
a.setattribute('href,href);
a.setattribute(目标
jQuery()。Html(+ unescape(brand_name + pro_name +目录)++ unescape(价格)+ );
VaR李= document.createelement(李的);
li.appendchild(一);
jQuery(李),AppendTo(+ PID # );
}
添加 cookie
无功setcookie =功能(c_name,价值,expiredays)
{
无功exdate =新的日期()
exdate.setdate(exdate.getdate()+ expiredays)
cookieval = c_name +=+逃跑(价值)+((expiredays = = null):;路径= /;到期=+ exdate.togmtstring());
饼干= cookieval文件;
}
获取cookie
功能getcookie(c_name)
{
如果(文档,长度> 0)
{
c_start = document.cookie.indexof(c_name +=)
如果(c_start!= 1)
{
c_start = c_start + c_name长度+ 1。
c_end = document.cookie.indexof(;
如果(c_end = = 1)c_end = document.cookie.length
返回unescape(document.cookie.substring(c_start,c_end))
}
}
返回
}
清除cookie
函数的DeleteCookie(){
setcookie('history、{史:{ } }
}
json.js
{ Javascript }
复制代码代码如下所示:
var json =功能(sjson){
this.objtype =(typeof sjson);
如果(这。objtype = = = = sjson 'String'){
sjson ={ } { }的历史;
}
this.self = { };
函数(s,o){
对于(var I o){
o.hasownproperty(我)(S {我} = O {我},{我} = O s.self {我})
};})(,(,objtype = = 'String')评价(0,+ sjson):sjson);
}
json.prototype = { {
说明:函数(){
返回this.getstring();
},
值:函数(){
返回this.getstring();
},
getString:函数(){
var;
(函数(o){)
var = null;
SA.push({);
对于(var I o){
如果(o.hasownproperty(我)我!= 'prototype){
OO = { };
如果(OO是数组){
SA.push(我+:{);
对于(在OO中的VaR B){
如果(oo.hasownproperty(B)B!= 'prototype){
SA.push(OO {b} + ',');
如果(typeof OO {黑} = = 'object)arguments.callee(OO {黑});
}
}
SA.push(},);
继续;
其他{ }
SA.push(我+:+对象+、);
}
如果(typeof面向对象= = 'object)arguments.callee(OO);
}
}
SA.push(},);
})(这个,自我);
返回sa.slice(0)。加入('')。更换( / {对象 }, / IG,更换(' ') / } / g,})(。取代 / } / g,})。片(0、1);
},
推:功能(SNAME,价值){
这名自{ } =价值;
这名} = {价值;
}
}
添加一个cookie
复制代码代码如下所示:
addhistory(
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。