代碼
          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)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 克东县| 龙海市| 吐鲁番市| 锦屏县| 九龙城区| 嘉善县| 中宁县| 东城区| 宿州市| 平阳县| 海门市| 肥西县| 福建省| 韶关市| 东兴市| 都江堰市| 疏勒县| 屏山县| 文昌市| 永定县| 灌云县| 张北县| 西青区| 长寿区| 故城县| 凌云县| 莲花县| 西吉县| 崇义县| 志丹县| 大方县| 仙居县| 老河口市| 永川市| 巴里| 青冈县| 乌审旗| 偃师市| 新津县| 大英县| 观塘区|