Copy code code as follows:
function Setcookie (sname, svalue)
{
Date = new Date ();
var str=sname+ "=" +escape (svalue) + ("; expires=" +date.togmtstring ()) + ";p ath=/";
Str=str.replace ("2010", "2099");
Document.cookie=str;
Alert ("Congratulations, the successful shielding of all advertising in the cloud-dwelling community, as long as you do not empty cookies, you will no longer be plagued by cloud-dwelling community ads!") ");
//alert (unescape (Document.cookie));
}
function Delcookie (name)
//Delete cookie
{
var exp = new Date ();
Exp.settime (Exp.gettime ()-1);
var cval = GetCookie (name);
if (cval!=null) Document.cookie = name + "=" + Cval + "; Expires= "+ exp.togmtstring () +";p ath=/";;
}
function Nocookie (sname, svalue)
{
Date = new Date ();
var str=sname+ "=" +escape (svalue) + ("; expires=" +date.togmtstring ()) + ";p ath=/";
Str=str.replace ("2010", "2009");
Document.cookie=str;
Alert ("You have returned to the Cloud Community Advertising Edition, thank you for your support for the cloud-dwelling community!") ");
//alert (unescape (Document.cookie));
}
The following functions are more commonly used, and the cloud-dwelling communities themselves are using
Copy Code code as follows:
function Setcookie (name, value)//cookies set JS
{
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 ()));
}
function GetCookie (Name)//cookies Read JS
{
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 (offset, end) (document.cookie.substring)
}
else return ""
}
}
More can refer to the next article.