zoukankan      html  css  js  c++  java
  • cookie应用——UI中查询条件的保存

    var cookieOperate = {
                cookieNames: {
                    companyCNName:"_companyCNName",
                    companyENName:"_companyENName",
                    status:"_ctatus",
                    anywords:"_anywords",
                    isExistingCustomers:"_isExistingCustomers",
                    city:"_city",
                    toDeliverGroupList:"_toDeliverGroupList",
                    isDistribution:"_isDistribution",
                    industry:"_industry",
                    source:"_source",
                    minConversionTime:"_minConversionTime",
                    maxConversionTime:"_maxConversionTime",
                    minDeliverTime:"_minDeliverTime",
                    maxDeliverTime:"_maxDeliverTime",
                    pageSize:"_pageSize",
                    countries:"_countries",
                    customersRequest:"_customersRequest"
                },
                expireDays:1,
                set: function (cookieName, value) {
                    var exdate = new Date();
                    exdate.setDate(exdate.getDate() + cookieOperate.expireDays);
                    document.cookie = cookieName + "=" + escape(value) +
                        ((cookieOperate.expireDays == null) ? "" : ";expires=" + exdate.toGMTString());
                },
                delete: function (cookieName) {
                    setCookie(cookieName, "", -1);
                },
                get: function (cookieName) {
                    if (document.cookie.length > 0) {
                        c_start = document.cookie.indexOf(cookieName + "=");
                        if (c_start != -1) {
                            c_start = c_start + cookieName.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 "";
                }
            }
    

      

    js保存cookie数据

    cookieOperate.set(cookieOperate.cookieNames.companyCNName, postRequst.CompanyCNName);
    

      

    js获取cookie数据

    postRequst.CompanyCNName=cookieOperate.get(cookieOperate.cookieNames.companyCNName)
    

      

  • 相关阅读:
    Assert.isTrue 用法
    P2967 [USACO09DEC]视频游戏的麻烦Video Game Troubles
    最近目标2333
    LibreOJ β Round #2」贪心只能过样例
    CF1062F Upgrading Cities 拓扑排序
    CF1108F MST Unification
    CF915D Almost Acyclic Graph 拓扑排序
    Swift日历控件Calendar
    README.md的markdown语法
    MAC打开App显示已损坏
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/10431851.html
Copyright © 2011-2022 走看看