zoukankan      html  css  js  c++  java
  • 测试1

    JQUERY.COOKIE

    Testing

    View Code
    jQuery.cookie = function(name, value, options) {
        if (typeof value != 'undefined') { // name and value given, set cookie
            options = options || {};
            if (value === null) {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                } else {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
            }
            // CAUTION: Needed to parenthesize options.path and options.domain
            // in the following expressions, otherwise they evaluate to undefined
            // in the packed version for some reason...
            var path = options.path ? '; path=' + (options.path) : '';
            var domain = options.domain ? '; domain=' + (options.domain) : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
        } else { // only name given, get cookie
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    };

    作者:未签收
    出处:http://www.cnblogs.com/tchoyi/
    声明:除特别标明之文章外,大部分整理自网络和小部分来自自己感悟,如有侵犯原作者版权的行为,可以随时与我联系!我会及时删除!

  • 相关阅读:
    Arduino-原理图标识
    python-垃圾回收机制
    利用浮力测密度
    sys模块-与python解释器交互的模块
    第十一章第二节 功率
    第十一章第一节 功
    类-描述器-把类对象方法转变为属性方式
    H5浏览器播放RTMP直播流
    如何查看某个端口被谁占用
    OBS第三方推流直播教程
  • 原文地址:https://www.cnblogs.com/tchoyi/p/2875531.html
Copyright © 2011-2022 走看看