Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
JS操作Cookie
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chen Liqiang  
View profile  
 More options Oct 14 2006, 2:56 am
From: "Chen Liqiang" <chen...@gmail.com>
Date: Fri, 13 Oct 2006 23:56:58 -0700
Local: Sat, Oct 14 2006 2:56 am
Subject: JS操作Cookie
function  GetCookieVal(offset)
//获得Cookie解码后的值
{
var  endstr  =  documents.cookie.indexOf  (";",  offset);
if  (endstr  ==  -1)
endstr  =  documents.cookie.length;
return  unescape(documents.cookie.substring(offset,  endstr));
}

function  SetCookie(name,  value)
//设定Cookie值
{
var  expdate  =  new  Date();
var  argv  =  SetCookie.arguments;
var  argc  =  SetCookie.arguments.length;
var  expires  =  (argc  >  2)  ?  argv[2]  :  null;
var  path  =  (argc  >  3)  ?  argv[3]  :  null;
var  domain  =  (argc  >  4)  ?  argv[4]  :  null;
var  secure  =  (argc  >  5)  ?  argv[5]  :  false;
if(expires!=null)  expdate.setTime(expdate.getTime()  +  (  expires  *
1000  ));
documents.cookie  =  name  +  "="  +  escape  (value)  +((expires  ==
null)  ?  ""  :  (";  expires="+  expdate.toGMTString()))
+((path  ==  null)  ?  ""  :  (";  path="  +  path))  +((domain  ==
null)  ?  ""  :  (";  domain="  +  domain))
+((secure  ==  true)  ?  ";  secure"  :  "");
}

function  DelCookie(name)
//删除Cookie
{
var  exp  =  new  Date();
exp.setTime  (exp.getTime()  -  1);
var  cval  =  GetCookie  (name);
documents.cookie  =  name  +  "="  +  cval  +  ";  expires="+
exp.toGMTString();
}

function  GetCookie(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;


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google