zoukankan      html  css  js  c++  java
  • cookie存储记录

    ////// 历史记录
            $(function () {
                // 标题
                var art_title = $("#Lbl_Hotel_Name").text();
                // 得到当前路径
                var art_url = document.URL;// 页面地址
                //得到code;
                var Art_code = art_url.substring(art_url.indexOf('?') + 1, 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(0, art_im.length - 4);
                var hz = art_im.substring(art_im.length - 4, art_im.length);
                var art_img = src + "s" + hz;
                // 星级;
                var art_start = $("#HotelStar").attr("src");
                // 初始可以插入cookie 信息;
                var len = 0;
                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 = 0;
                    if (len > 5) {
                        start = 1;
                    }
                    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: 1 });
                }
            });
    
            $(function () {
                //清空历史记录
                //$.cookie("hisArt", null);
                var json = eval("(" + $.cookie("hisArt") + ")");
                var list = "";
                for (var i = 0; i < json.length - 1; 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 = 0; 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>

  • 相关阅读:
    Uva 10779 collector's problem
    poj 2728 最优比率树(最小生成树问题)
    LA 3126 二分图匹配 最小路径覆盖
    poj 1149 最大流构图
    Step By Step(Java XML篇)
    Step By Step(Java 输入输出篇)
    Step By Step(Java 集合篇)
    Step By Step(Java 线程篇)
    Step By Step(Java 反射篇)
    Step By Step(Java 国际化篇)
  • 原文地址:https://www.cnblogs.com/juexin/p/3474494.html
Copyright © 2011-2022 走看看