


Cookie recent browsing history (Chinese escape transcoding) specific implementation_javascript skills
[javascript]
/**
*pro_id: product id
*brand_name: brand
*pro_name: product id
*price: price
* catalog: model
* img: picture
*file_name : File name
*/
var addHistory=function(pro_id,brand_name,pro_name,price,catalog,img,file_name){
stringCookie=getCookie('history');
var stringHistory=""!=stringCookie?stringCookie:"{history:[]}";
var json=new JSON(stringHistory);
var pro_ids = '' ;
jQuery.each(json['history'],function(i,val){
pro_ids =json['history'][i].pro_id "," ;
}) ;
if(jQuery.trim(pro_id)=='' || pro_ids.indexOf(pro_id)==-1){
var e="{pro_id:" pro_id ",brand_name:'" brand_name "',pro_name:'" pro_name "',price:'" price "',catalog:'" catalog "',img:'" img "',file_name:'" file_name "'}";
json['history'].push(e); //添加一个新的记录
setCookie('history',json.toString(),30);
}
}
//显示历史记录
var DisplayHistory=function(){
var p_ele=document.getElementById('history');
while (p_ele.firstChild) {
p_ele.removeChild(p_ele.firstChild);
}
var historyJSON=getCookie('history');
var json=new JSON(historyJSON);
var displayNum=6;
for(i=json['history'].length-1;i>=0;i--){
addLi(json['history'][i]['pro_id'],json['history'][i]['brand_name'],json['history'][i]['pro_name'],json['history'][i]['price'],json['history'][i]['catalog'],json['history'][i]['img'],json['history'][i]['file_name'],"history");
displayNum--;
if(displayNum==0){break;}
}
}
//添加一个cookie
var addLi=function(pro_id,brand_name,pro_name,price,catalog,img,file_name,pid){
var a=document.createElement('a');
var href='/proDetail/' file_name;
a.setAttribute('href',href);
a.setAttribute("target","_blank") ;
jQuery(a).html("
" unescape(brand_name pro_name catalog) "
" unescape(price) "") ;var li=document.createElement('li');
li.appendChild(a);
jQuery(li).appendTo("#" pid) ;
}
//添加cookie
var setCookie=function(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate() expiredays)
cookieVal=c_name "=" escape(value) ((expiredays==null) ? "" : ";path=/;expires=" exdate.toGMTString());
document.cookie=cookieVal;
}
//获取cookie
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name "=")
if (c_start!=-1)
{
c_start=c_start c_name.length 1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return ""
}
// 清除cookie
function DeleteCookie(){
setCookie('history',"{history:[]}",30);
}
json.js
[javascript]
var JSON = function(sJSON){
this.objType = (typeof sJSON);
if(this.objType=='string' && ''==sJSON){
sJSON = '{history:[]}' ;
}
this.self = [];
(function(s,o){
for(var i in o){
o.hasOwnProperty(i)&&(s[i]=o[i],s.self[i]=o[i])
};})(this,(this.objType=='string')?eval('0,' sJSON):sJSON);
}
JSON.prototype = {
toString:function(){
return this.getString();
},
valueOf:function(){
return this.getString();
},
getString:function(){
var sA = [];
(function(o){
var oo = null;
sA.push('{');
for(var i in o){
if(o.hasOwnProperty(i) && i!='prototype'){
oo = o[i];
if(oo instanceof Array){
sA.push(i ':[');
for(var b in oo){
if(oo.hasOwnProperty(b) && b!='prototype'){
sA.push(oo[b] ',');
if(typeof oo[b]=='object') arguments.callee(oo[b]);
}
}
sA.push('],');
continue;
}else{
sA.push(i ':'' oo '',');
}
if(typeof oo=='object') arguments.callee(oo);
}
}
sA.push('},');
})(this.self);
return sA.slice(0).join('').replace(/[object object],/ig,'').replace(/,}/g,'}').replace(/,]/g,']').slice(0,-1);
},
push:function(sName,sValue){
this.self[sName] = sValue;
this[sName] = sValue;
}
}
Add a cookie
addHistory("<%=uuid%>",escape("<%=factoryname%>"),escape("<%=name%>"),escape("<%=price% >"),escape("<%=catalogname%>"),escape("<%=img%>"),escape("<%=file_name%>"));

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

Cookies are usually stored in the cookie folder of the browser. Cookie files in the browser are usually stored in binary or SQLite format. If you open the cookie file directly, you may see some garbled or unreadable content, so it is best to use Use the cookie management interface provided by your browser to view and manage cookies.

Cookies on your computer are stored in specific locations on your browser, depending on the browser and operating system used: 1. Google Chrome, stored in C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data\Default \Cookies etc.

How to View Command History in Linux In Linux, we use the history command to view the list of all previously executed commands. It has a very simple syntax: history Some options for pairing with the history command include: Option description -c clears the command history for the current session -w writes the command history to a file -r reloads the command history from the history file -n Limit the number of output of recent commands Simply run the history command to see a list of all previously executed commands in a Linux terminal: In addition to viewing command history, you can also manage command history and perform modifications to previously executed commands , reverse search command history or even delete history completely

Cookies on the mobile phone are stored in the browser application of the mobile device: 1. On iOS devices, Cookies are stored in Settings -> Safari -> Advanced -> Website Data of the Safari browser; 2. On Android devices, Cookies Stored in Settings -> Site settings -> Cookies of Chrome browser, etc.

The dangers of cookie leakage include theft of personal identity information, tracking of personal online behavior, and account theft. Detailed introduction: 1. Personal identity information is stolen, such as name, email address, phone number, etc. This information may be used by criminals to carry out identity theft, fraud and other illegal activities; 2. Personal online behavior is tracked and analyzed through cookies With the data in the account, criminals can learn about the user's browsing history, shopping preferences, hobbies, etc.; 3. The account is stolen, bypassing login verification, directly accessing the user's account, etc.

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

The working principle of cookies involves the server sending cookies, the browser storing cookies, and the browser processing and storing cookies. Detailed introduction: 1. The server sends a cookie, and the server sends an HTTP response header containing the cookie to the browser. This cookie contains some information, such as the user's identity authentication, preferences, or shopping cart contents. After the browser receives this cookie, it will be stored on the user's computer; 2. The browser stores cookies, etc.
