asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
function Setcookie (name, value) { //设置名称为name,值为value的Cookie
var argc = SetCookie.arguments.length;
var argv = SetCookie.arguments;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;


documents.cookie = name + "=" + value +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function Deletecookie (name) { //删除名称为name的Cookie
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
documents.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function Clearcookie() //清除COOKIE
{
var temp=documents.cookie.split(";");
var loop3;
var ts;
for (loop3=0;loop3 {
ts=temp[loop3].split("=")[0];
if (ts.indexOf(’mycat’)!=-1)
DeleteCookie(ts); //如果ts含“mycat”则执行清除
}
}

function getCookieVal (offset) { //取得项名称为offset的cookie值
var endstr = documents.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = documents.cookie.length;
return unescape(documents.cookie.substring(offset, endstr));
}

function GetCookie (name) { //取得名称为name的cookie值
var arg = name + "=";
var alen = arg.length;
var clen = documents.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (documents.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = documents.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
//
function Setcookie (name, value) { //设置名称为name,值为value的Cookie
var argc = SetCookie.arguments.length;
var argv = SetCookie.arguments;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;


documents.cookie = name + "=" + value +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function Deletecookie (name) { //删除名称为name的Cookie
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
documents.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function Clearcookie() //清除COOKIE
{
var temp=documents.cookie.split(";");
var loop3;
var ts;
for (loop3=0;loop3 {
ts=temp[loop3].split("=")[0];
if (ts.indexOf(’mycat’)!=-1)
DeleteCookie(ts); //如果ts含“mycat”则执行清除
}
}

function getCookieVal (offset) { //取得项名称为offset的cookie值
var endstr = documents.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = documents.cookie.length;
return unescape(documents.cookie.substring(offset, endstr));
}

function GetCookie (name) { //取得名称为name的cookie值
var arg = name + "=";
var alen = arg.length;
var clen = documents.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (documents.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = documents.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
//3
不知有没有人贴过~
<html>
<head></head>
<body>
<script>
<!--Hide
if(document.cookie==""){
document.write("There are no cookie here !")
}
else{
thisCookie=document.cookie.split(",")
for(i=0;i<thisCookie.length;i++){
document.write("Cookie.name is'"+thisCookie[i].split("=")[0])
document.write("',and the value is '"+thisCookie[i].split("=")[1]+"'<br>")
}
}
//End-->
</script>
</body>
</html>

我又忘了[]的问题。已经改正。
posted on 2006-03-29 01:26 汪杰 阅读(194) 评论(0)  编辑 收藏 引用 所属分类: javascript
只有注册用户登录后才能发表评论。

<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 468991
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜