Home » jQuery 外掛

[jQ]aqCookie 1.0

範例 1
沒錯!只要 300 元就能獲得我們團隊完整的協助,讓效果能迅速的整合到您的網站,並保證瀏覽器的相容性。
立刻申請!

aqCookie_1_0

當想要記住瀏覽者的一些客制化的設定時,除了使用資料庫來記錄之外,如果並不是很特別重要的設定的話,或者可以考慮使用 aqCookie 的方式來記錄。

套件名稱:aqCookie
套件版本:1.0
作者網站:http://aquaron.com/~jquery/aqCookie
套件網址:http://plugins.jquery.com/project/aqCookie
發佈日期:2008-10-31
檔案大小:1.01 KB
檔案下載:aqCookie.js

方法說明:

檢視原始碼 JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 設定 cookie;若沒給 value 則表示刪除該 cookie
$.aqCookie.set(name, value);
 
// 取得 cookie;不管是只給 name 或是陣列都會回傳一個陣列值,其中 name 是索引值
$.aqCookie.get(name | [array]);
 
// 刪除 cookie;也可以用 set(name) 的方式
$.aqCookie.del(name);
 
// 使用正規表示法的方式來取得 cookie 值;其中的索引值為符合的名稱
$.aqCookie.all(regex filter);
 
// 設定 domain 值;預設是 ''
$.aqCookie.domain = string;
 
// 設定 cookie 多久過期;預設是 3153600000(約36.5天...)
$.aqCookie.secToExpire = number;

使用範例:

檢視原始碼 JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="aqCookie.js"></script>
<style type="text/css">
	.brownbox {
		width: 160px;
	}
</style>
<script type="text/javascript">
	$(function(){
		// 設定 cookie
		$(":button[value=Set cookie]").click(function(){
			var _key = $(":text[name=key]").val();
			if(!_key) return false;
			$.aqCookie.set('__'+_key, $(":text[name=val]").val());
			return false;
		});
 
		// 取得 cookie
		$(":button[value=Get cookie]").click(function(){
			var _gkey = $(":text[name=gkey]").val();
			var _arry = $.aqCookie.get('__'+_gkey);
			alert(_arry['__'+_gkey]);
			return false;
		});
 
		// 刪除 cookie
		$(":button[value=Get cookie]").click(function(){
			var arry = $.aqCookie.del('__'+$(":text[name=gkey]").val());
			return false;
		});
	});
</script>
 
<body>
	<div class="brownbox">
		<input class="txt" type="text" name="key">
		<input class="txt" type="text" name="val">
		<input class="btn" type="button" value="Set cookie">
	</div>
	<div class="brownbox">
		<input class="txt" type="text" name="gkey">
		<input class="btn" type="button" value="Get cookie">
		<input class="btn" type="button" value="Delete">
	</div>
</body>
範例 1

檔案描述
基本的範例檔案(免空) 開始下載
基本的範例檔案 會員限定

也許您對這些文章也有興趣

  • [jQ]Mouse Wheel Extension 3.0.6
  • [jQ]Cookie 1.0
  • [jQ]jAngle 0.5
  • [jQ]jFontSize 1.0
  • [jQ]jRumble 1.3
  • [jQ]Textualizer 2.3.1

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>