代碼
          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 閱讀(216) 評論(0)  編輯  收藏

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


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 陈巴尔虎旗| 平罗县| 吴桥县| 镇赉县| 靖远县| 土默特右旗| 大埔县| 罗甸县| 长海县| 绥化市| 柘荣县| 古丈县| 柳江县| 时尚| 交口县| 锡林郭勒盟| 文水县| 石河子市| 马公市| 翁牛特旗| 乌什县| 得荣县| 甘孜县| 富宁县| 卢氏县| 九江市| 成安县| 额敏县| 江门市| 鄯善县| 吉首市| 青河县| 合肥市| 仪陇县| 上蔡县| 蓬溪县| 集安市| 永新县| 鹿邑县| 黄石市| 连南|