欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript js cookie的存儲,獲取和刪除

 更新時間:2007年12月29日 20:16:19   作者:  
javascript js cookie的存儲,獲取和刪除
使用方法:

//1、存儲Cookie
//2、參數(shù)說明: 1、參數(shù)1:Cookie存儲Name,參數(shù)2:Cookie要存儲的值
//3、例子如下:
setCookie('Method',match);

//1、獲取Cookie
//2、參數(shù)說明: 1、參數(shù)1:Cookie存儲的Name
//3、例子如下:
getCookie('Method')

//1、刪除Cookie
//2、參數(shù)說明: 1、參數(shù)1:Cookie存儲的Name
//3、例子如下:
deleteCookie('Method');

函數(shù)如下:

復制代碼 代碼如下:

<script language=javascript> 
/**//************************************************************************ 
|    函數(shù)名稱: setCookie                                                | 
|    函數(shù)功能: 設置cookie函數(shù)                                            | 
|    入口參數(shù): name:cookie名稱;value:cookie值                        | 
|    維護記錄: Spark(創(chuàng)建)                                            | 
|    版權所有: (C) 2006-2007 北京東方常智科技有限公司                    | 
|    編寫時間: 2007年9月13日 21:00                                        | 
*************************************************************************/ 
function setCookie(name, value)  
...{  
   var argv = setCookie.arguments;  
   var argc = setCookie.arguments.length;  
   var expires = (argc > 2) ? argv[2] : null;  
   if(expires!=null)  
   ...{  
       var LargeExpDate = new Date ();  
       LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));          
   }  
   document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));  

/**//************************************************************************ 
|    函數(shù)名稱: getCookie                                                | 
|    函數(shù)功能: 讀取cookie函數(shù)                                            | 
|    入口參數(shù): Name:cookie名稱                                            | 
|    維護記錄: Spark(創(chuàng)建)                                            | 
|    版權所有: (C) 2006-2007 北京東方常智科技有限公司                    | 
|    編寫時間: 2007年9月13日 21:02                                        | 
*************************************************************************/ 
function getCookie(Name)  
...{  
   var search = Name + "="  
   if(document.cookie.length > 0)  
   ...{  
       offset = document.cookie.indexOf(search)  
       if(offset != -1)  
       ...{  
           offset += search.length  
           end = document.cookie.indexOf(";", offset)  
           if(end == -1) end = document.cookie.length  
           return unescape(document.cookie.substring(offset, end))  
       }  
       else return ""  
   }  
}  

/**//************************************************************************ 
|    函數(shù)名稱: deleteCookie                                            | 
|    函數(shù)功能: 刪除cookie函數(shù)                                            | 
|    入口參數(shù): Name:cookie名稱                                        | 
|    維護記錄: Spark(創(chuàng)建)                                        | 
|    版權所有: (C) 2006-2007 北京東方常智科技有限公司                | 
|    編寫時間: 2007年9月15日 18:10                                    | 
*************************************************************************/     
function deleteCookie(name)  
...{  
                    var expdate = new Date();  
                    expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));  
   setCookie(name, "", expdate);  
}  
</script>

相關文章

最新評論