js读取cookie字典
来源:互联网 发布:淘宝达人有用吗 编辑:程序博客网 时间:2024/05/29 16:50
前面写到过asp读取cookies字典的
现在写一个js读取cookies的字典的
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="zourinet">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script language="JavaScript">
<!--
function Cookies()
{
this.name;
this.path="/";
expires=new Date();
expires.setTime(expires.getTime()+(86400*365));
this.expires = expires.toGMTString();
}
Cookies.prototype.SetCookie=function (name,value)
{
document.cookie=name+"="+value+"; expires="+this.expires+"; path="+this.path+"";
}
Cookies.prototype.getCookie=function (Name)
{
var search = Name + "=";
if (document.cookie.length > 0)
{ // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1)
{ // if cookie exists
offset += search.length ;
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
return (unescape(document.cookie.substring(offset, end)));
}
}
return 0;
}
//未完等等[20070825]
Cookies.prototype.getCookieDic=function(vparent,vchildren)
{
var strchildren = this.getCookie(vparent);
strchildren = strchildren.getQuery(vchildren);
return (strchildren);////20070827 完成
}
String.prototype.getQuery = function(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = this.substr(this.indexOf("/?")+1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
var c = new Cookies();
c.SetCookie("person","name=zourinet&id=22");
alert(c.getCookieDic("person","id"));
//-->
</script>
</body>
</html>
完成.
现在写一个js读取cookies的字典的
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="zourinet">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script language="JavaScript">
<!--
function Cookies()
{
this.name;
this.path="/";
expires=new Date();
expires.setTime(expires.getTime()+(86400*365));
this.expires = expires.toGMTString();
}
Cookies.prototype.SetCookie=function (name,value)
{
document.cookie=name+"="+value+"; expires="+this.expires+"; path="+this.path+"";
}
Cookies.prototype.getCookie=function (Name)
{
var search = Name + "=";
if (document.cookie.length > 0)
{ // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1)
{ // if cookie exists
offset += search.length ;
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
return (unescape(document.cookie.substring(offset, end)));
}
}
return 0;
}
//未完等等[20070825]
Cookies.prototype.getCookieDic=function(vparent,vchildren)
{
var strchildren = this.getCookie(vparent);
strchildren = strchildren.getQuery(vchildren);
return (strchildren);////20070827 完成
}
String.prototype.getQuery = function(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = this.substr(this.indexOf("/?")+1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
var c = new Cookies();
c.SetCookie("person","name=zourinet&id=22");
alert(c.getCookieDic("person","id"));
//-->
</script>
</body>
</html>
完成.
- js读取cookie字典
- js 设置cookie 读取cookie
- JS设置cookie、读取cookie
- js读取设置Cookie
- JS读取写入COOKIE
- js读取Cookie值
- js写入读取cookie
- js 读取 cookie
- js读取 写入 cookie
- JS 读取写入 Cookie ;
- js 获取读取cookie
- js 读取cookie
- js 设置读取cookie
- js 设置 读取cookie
- js读取cookie
- JS设置cookie、读取cookie、删除cookie
- JS设置cookie、读取cookie、删除cookie
- JS设置cookie、读取cookie、删除cookie
- SharpDevelop源码分析 (三、插件系统)
- 数据控件 (gridview,repeater等) 操作子控件
- ESQL/C资料(完全版)三
- ESQL/C资料(完全版)四
- 编译时出现:请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如Page 或UserControl)是正确的。
- js读取cookie字典
- ASE的sqlsrvr(dataserver) 的启动参数-T 汇集
- RARP:反向地址转换协议
- 简单的分页效果(servlet实现)
- pb中获得本机IP地址的另一个方法
- 单词记忆王源代码
- PHP cookie和session的分析 (转)
- test
- 彻底杜绝PHP的session cookie错误(转)