• 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)
    

      

  • 相关阅读:
    mysql数据库基本类型
    常用辅助类【转】
    Java 并发笔记】并发机制底层实现整理[转发]
    关于PROPAGATION_NESTED的理解
    线程数设置
    c# Expression 扩展[转]
    Net定时器 【转载】
    【转】高可用设计-58沈剑
    【转】委托的三种调用示例(同步调用 异步调用 异步回调)
    [coursera OA] acme match
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/10431851.html
Copyright © 2020-2023  润新知