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

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 嘉义市| 福建省| 建湖县| 堆龙德庆县| 郸城县| 西乡县| 云阳县| 武夷山市| 苏州市| 永胜县| 龙州县| 江华| 含山县| 黄石市| 平乐县| 延安市| 富宁县| 乐都县| 新沂市| 漳州市| 广水市| 华容县| 开封市| 靖江市| 太原市| 馆陶县| 江口县| 柘荣县| 鸡东县| 晋州市| 什邡市| 绥中县| 定日县| 广饶县| 嘉义市| 资溪县| 宜州市| 庆阳市| 青浦区| 海南省| 新巴尔虎右旗|