页面本地缓存和Cookie缓存
Web.storage = {
    isStorageSupported: function () {
        try {
            return window.localStorage;
        } catch (err) {
            return false;
        }
    },
    getstore: function (name) {
        var a = this;
        if (a.isStorageSupported) {
            return localStorage.getItem(name);
        }
        else {
            return a.getCookie(name);
        }
    },
    setstore: function (name, value) {
        var a = this;
        if (a.isStorageSupported) {
            localStorage.setItem(name, value);
        }
        else {
            a.setCookie(name, value);
        }
    },
    delstore: function (name) {
        var a = this;
        if (a.isStorageSupported) {
            localStorage.removeItem(name);
        }
        else {
            a.delCookie(name);
        }
    },
    clearstore: function () {
        var a = this;
        if (a.isStorageSupported) {
            localStorage.clear();
        }
        else {
            a.clearCookie();
        }
    },
    getCookie: function (name) {
        var cookie_start = document.cookie.indexOf(name + "="),
        cookie_end = document.cookie.indexOf(";", cookie_start);
        return -1 == cookie_start ? "" : unescape(document.cookie.substring(cookie_start + name.length + 1, cookie_end > cookie_start ? cookie_end : document.cookie.length))
    },
    setCookie: function (name, value, isSession) {
        var expires = new Date;
        expires.setTime(expires.getTime() + 2592e6);
        var path_domain = "; path=/" + (-1 != document.domain.indexOf("vdian.com") ? "; domain=vdian.com" : -1 != document.domain.indexOf("koudai.com") ? "; domain=koudai.com" : -1 != document.domain.indexOf("weidian.com") ? "; domain=weidian.com" : "");
        if ("object" == typeof name) for (var v in name) {
            var cookie_content = escape(v) + "=" + escape(name[v]);
            document.cookie = cookie_content + "; expires=" + expires.toGMTString() + path_domain
        } else {
            var cookie_content = escape(name) + "=" + escape(value);
            document.cookie = cookie_content + (isSession ? "" : "; expires=" + expires.toGMTString()) + path_domain
        }
    },
    delCookie: function (name) {
        var path_domain = "; path=/" + (-1 != document.domain.indexOf("vdian.com") ? "; domain=vdian.com" : -1 != document.domain.indexOf("koudai.com") ? "; domain=koudai.com" : -1 != document.domain.indexOf("weidian.com") ? "; domain=weidian.com" : "");
        document.cookie = escape(name) + "=; expires=" + new Date(0).toUTCString() + path_domain;
        try {
            "M_b_id" === name && VTrace && VTrace.setFuncTrace("delCookie_id", !0)
        } catch (e) { }
    }, 
    clearCookie: function () {
        var _keys = document.cookie.match(/[^ =;]+(?=\=)/g);
        if (_keys) for (var l = _keys.length,
        i = l; i--;) M.delCookie(_keys[i]);
        try {
            VTrace && VTrace.setFuncTrace("clearCookie", !0)
        } catch (e) { }
    }
}

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号