• js 设置cookie转


    原文地址: http://www.cnblogs.com/wwcherish/archive/2013/04/17/3026848.html

    <script type="text/javascript">
            function Get_Cookie(name) {
                var start = document.cookie.indexOf(name + "=");
                var len = start + name.length + 1;
                if ((!start) && (name != document.cookie.substring(0, name.length))) return null;
                if (start == -1) return null;
                var end = document.cookie.indexOf(";", len);
                if (end == -1) end = document.cookie.length;
                return decodeURI(document.cookie.substring(len, end));
            }

            function Set_Cookie(name, value, expires, path, domain, secure) {
                expires = expires * 60 * 60 * 24 * 1000;
                var today = new Date();
                var expires_date = new Date(today.getTime() + (expires));
                var cookieString = name + "=" + decodeURIComponent(value)/** encodeURIComponent(value) 貌似也行**/ +
                     ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
                     ((path) ? ";path=" + path : "") +
                     ((domain) ? ";domain=" + domain : "") +
                     ((secure) ? ";secure" : "");
                document.cookie = cookieString;
            }

            //页面加载
            $(function () {

                Set_Cookie('dynewform_name', 'zhuname', 36500);
                var nameone = Get_Cookie("dynewform_name");
               
                 alert(nameone)  //==>zhuname
            });
        </script>

  • 相关阅读:
    Windows Azure Cloud Service (6) Reboot and Reimage
    Windows Azure Platform Introduction (7) Windows Azure Host OS 和 Guest OS
    Nod32的内网升级方案
    32位色
    ASP.NET 2.0 的内部变化
    关于Nod的离线升级方案
    光、色、补色
    解决迅雷的“重复任务提示”
    Nod32Viewer不能取得最新的镜像包的问题
    火车头实在是太好玩了
  • 原文地址:https://www.cnblogs.com/ry123/p/3040904.html
Copyright © 2020-2023  润新知