cookie存储记录
////// 历史记录
$(function () {
// 标题
var art_title = $("#Lbl_Hotel_Name").text();
// 得到当前路径
var art_url = document.URL;// 页面地址
//得到code;
var Art_code = art_url.substring(art_url.indexOf('?') + , art_url.length);
// var art_code = $("#yincang").val();
// 价格 ;
var art_price = $("#Hotelprice").text();
//币种
var art_Money = $("#Money").text();
// 图片;
var art_im = $("#images_small li:first img ").attr("src");
var src = art_im.substring(, art_im.length - );
var hz = art_im.substring(art_im.length - , art_im.length);
var art_img = src + "s" + hz;
// 星级;
var art_start = $("#HotelStar").attr("src");
// 初始可以插入cookie 信息;
var len = ;
var canAdd = true; var hisArt = $.cookie("hisArt"); if (hisArt) {
hisArt = eval("(" + hisArt + ")");
len = hisArt.length;
}
/////////////////
// 如果浏览信息已经存在 则终止;
//$(hisArt).each(function () { // if (this.title = art_title) {
// canAdd = false;// 已经存在;
// return false;
// } //}); if (canAdd == true) {
// 构建json 数据
var json = "[";
var start = ;
if (len > ) {
start = ;
}
for (var i = start; i < len; i++) {
json = json + "{\"title\":\"" + hisArt[i].title + "\",\"Money\":\"" + hisArt[i].Money + "\",\"HotelPrice\":\"" + hisArt[i].HotelPrice + "\",\"HotelImg\":\"" + hisArt[i].HotelImg + "\",\"Img_Start\":\"" + hisArt[i].Img_Start + "\",\"Code\":\"" + hisArt[i].Code + "\"},";
}
json = json + "{\"title\":\"" + art_title + "\",\"Money\":\"" + art_Money + "\",\"HotelPrice\":\"" + art_price + "\",\"HotelImg\":\"" + art_img + "\",\"Img_Start\":\"" + art_start + "\",\"Code\":\"" + Art_code + "\"}]"; $.cookie("hisArt", json, { path: "/" }, { expires: });
}
}); $(function () {
//清空历史记录
//$.cookie("hisArt", null);
var json = eval("(" + $.cookie("hisArt") + ")");
var list = "";
for (var i = ; i < json.length - ; i++) {
list = list + "<div class='div1'><dl><dt><a href='<%=CSweb%>Templete/HotelOutside/HotelInfo.aspx?Code=" + json[i].Code + "'><img src=" + json[i].HotelImg + " /></a></dt><dd ><p class='p1'><a href='<%=CSweb%>Templete/HotelOutside/HotelInfo.aspx?Code=" + json[i].Code + "'>" + json[i].title + "</a></p>" + "<p class='p2'><span style='margin_right:34px'>4星</span>" + json[i].Money + json[i].HotelPrice + "</p></dd></dl><div><a href='#3'><img src=/images/xj_bi.jpg' /></a></div></div>" }
$("#list").html(list); });
取:
$(function () {
//清空历史记录
//$.cookie("hisArt", null);
var json = eval("(" + $.cookie("hisArt") + ")");
//alert(json);
var list = "<div class='LickTit' > <span class='LickIcon'></span><h2 >我的浏览记录</h2></div>";
for (var i = ; i < json.length; i++) {
list = list + "<div class='Lishi'><div class='Lishiimg'><a href='<%=CSweb%>Templete/HotelOutside/HotelInfo.aspx?Code=" + json[i].Code + "'><img src=" + json[i].HotelImg + " /></a> </div> <div class='Lishifont'> <p class='LishiP'> <a href='<%=CSweb%>Templete/HotelOutside/HotelInfo.aspx?Code=" + json[i].Code + "' class='Lishihref'>" + json[i].title + "</a></p><p class='LishiP'><span class='lsspan'>4星</span> </p> <p class='LishiP LishiP_bt'> <span class='lsspan'>" + json[i].Money + json[i].HotelPrice + "</span><a href='<%=CSweb%>Templete/HotelOutside/HotelInfo.aspx?Code=" + json[i].Code + "' class='lsahrf'>查看</a> </p> <a href='javascript:;' class='lishiNot'></a></div> </div> "
}
$("#list").html(list);
$("#<%=cbl_Facility.ClientID%>").change(function () {
});
});
引用资源:
<script type="text/javascript" src="../js/jq.page/jquery.cookie.js"></script>
cookie存储记录的更多相关文章
- 通过localstorage和cookie实现记录文章的功能
我们在做页面的时候,会考虑记录用户曾经看过的文章的功能,并记录下来在页面中显示!但是在IE低版本的下是不支持localstorage的功能,只能采用cookie来代替本地存储的功能!实现的方法如下! ...
- js读写Cookie问题(Cookie存储时长、Cookie存储域)汇总
在采集网站用户行为数据/使用js对用户行为做交互时,经常会使用到Cookie,了解Js Cookie的读写,以及一些细节,非常重要. 什么是Cookie 所谓Cookie,只是一条极为短小的信息, ...
- cookie : 存储数据
cookie : 存储数据,当用户访问了某个网站(网页)的时候,我们就可以通过cookie来像访问者电脑上存储数据 1.不同的浏览器存放的cookie位置不一样,也是不能通用的 2.cookie的存储 ...
- SetCookies, cookie规范注册表和cookie存储将会优先于设置在HTTP客户端级别中默认的那些
遇到下面问题解决方法: Hey? 404 抱歉,你输入的网址可能不正确,或者该网页不存在. 7 秒后返回首页 使用独立的本地执行上下文来实现对每个用户(或每个线程)状态的管理. 定义在本地内容中的co ...
- cookie存储对象信息
最近看到某公司某项目中用于保存多个城市信息到cookie中的方法,该方法的逻辑是按时间顺序记录最近访问过的三个城市的名字及id,逻辑包插入与含排重.插入与排重的代码如下: 1 2 3 4 5 6 7 ...
- Cookie存储中文报错:java.lang.IllegalArgumentException: Control character in cookie value or attribute.(转)
项目中做自动登录和保存密码时,Cookie报错Java.lang.IllegalArgumentException,上google查了下 在http://hi.baidu.com/xtxycy/blo ...
- js cookie存储方法
/*! * jQuery Cookie Plugin v1.4.0 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Kla ...
- jQuery 操作Cookie 存储 读取 删除等
<script type="text/javascript" src="/UI.Web.CRM.Main/js/jquery-2.1.1.min.js"& ...
- js基础---cookie存储
一.Cookie是什么Cookie是一种客户端(浏览器)把用户信息以文件形式存储到本地硬盘的技术,说白了就是一种浏览器技术 二.Cookie的作用Cookie的作用很单一,就是存储客户数据.(存储数据 ...
随机推荐
- AWR快照管理
创建快照: SQL> exec dbms_workload_repository.create_snapshot(); 删除快照: SQL> exec dbms_workload_repo ...
- ios app下载跳到itunes
<body class="box"> <div class="text"> <a href="https://itune ...
- XMPP协议介绍
一.xmpp协议工作原理 二.XMPP地址模式 三.xmpp消息格式 xmpp xml包括三个元素,message,presence,iq,也翻译做三种节. 在'jabber:client'和'jab ...
- 理解MapReduce
理解MapReduce Hadoop的MapReduce过程具有如下形式: 1) map: (K1, V1) => list(K2, V2) 2) redu ...
- (Abstract Factory)抽象工厂
定义: 抽象工厂同工厂方法有相似处:都提供了对子类创建的封装,都是有工厂方法的接口实现类的中决定了子类被创建为什么对象. 不同于工厂方法之处:工厂方法创建的对象只是一个类型的子类,而抽象工厂创建的对象 ...
- Effective C++ 3.资源管理
//条款13:以对象管理资源 // 1.C++程序中最常使用的资源就是动态分配内存,并且还包括文件描述器,互斥锁,GDI对象.数据库连接.网络socket等.不管哪一种资源,当不再使用的时候必须将其归 ...
- configs for postgresql restart and postgresql reload
-- configs requiring postgresql restart select name, setting, context from pg_settings where context ...
- G面经prepare: Sort String Based On Another
Given a sorting order string, sort the input string based on the given sorting order string. Ex sort ...
- C# 动态链接库的创建
首先在C#工程下面安装第三方插件包 安装方法:Tools --> Library Package Manager --> Package Manager Console Install-P ...
- C++之路进阶——bzoj1823(满汉全席)
F.A.Qs Home Discuss ProblemSet Status Ranklist Contest ModifyUser hyxzc Logout 捐赠本站 Notice:由于本OJ建立在 ...