代碼
          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
                  }
                  
          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;
              }
          };

           

          posted on 2010-08-11 11:49 sanmao 閱讀(217) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 汤阴县| 资中县| 淳化县| 洪雅县| 浦东新区| 新密市| 醴陵市| 遵义县| 都江堰市| 扶余县| 伊宁县| 兴宁市| 陵水| 乌苏市| 淳安县| 长乐市| 光泽县| 长垣县| 响水县| 河西区| 盈江县| 平南县| 梁山县| 东乌珠穆沁旗| 吉隆县| 威海市| 彰化县| 大足县| 辽宁省| 临湘市| 兰州市| 高碑店市| 陆川县| 墨竹工卡县| 泰安市| 东乡县| 大冶市| 小金县| 汶川县| 宁南县| 洪江市|