• cookie设置、获取、删除


    var cookie={
        set: function(name, value, expires, path, domain){
            if(!expires){
                expires = -1;
            }
            if(!path){
                path = "/";
            }
            var d = "" + name + "=" + value;
            var e;
            if(expires < 0){
                e = "";
            }else if(expires == 0){
                var f = new Date(1970, 1, 1);
                e = ";expires=" + f.toUTCString();
            }else{
                var now = new Date();
                var f = new Date(now.getTime() + expires * 1000);
                e = ";expires=" + f.toUTCString();
            }
            var dm;
            if(!domain){
                dm = "";
            }else{
                dm = ";domain=" + domain;
            }
            
            document.cookie = name + "=" + escape(value) + ";path=" + path + e + dm;
        }, 
    
        get: function(name){
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i = 0; i < ca.length; i++){
                var c = ca[i];
                while(c.charAt(0) == ' '){
                    c = c.substring(1, c.length);
                }
                if(c.indexOf(nameEQ) == 0){
                    return decodeURIComponent(c.substring(nameEQ.length, c.length))
                }
            }
    
            return null;
        },
    
        del: function(name){
            this.set(name, "", -1);
        }
    };
    
  • 相关阅读:
    java 命令
    测试事件响应修改界面内容
    ASP.NET MVC 解决账号重复登录问题
    Redis 安装
    js返回页面顶部
    Brackets 前端编辑器推荐
    一点点............
    响应式——em,rem,px
    新知识——响应式
    面试心得
  • 原文地址:https://www.cnblogs.com/stone-it/p/7326956.html
Copyright © 2020-2023  润新知