Recently, due to the need to control advertisements, we sorted out some operation control code for cookies on the pages of lumeng and his/her feet.
The Code is as follows:
Function SetCookie (sName, sValue)
{
Date = new Date ();
Var str = sName + "=" + escape (sValue) + ("; expires =" + date. toGMTString () + "; path = /";
Str = str. replace ("2010", "2099 ");
Document. cookie = str;
Alert ("Congratulations, you have successfully blocked all ads for the home of the feet. As long as you do not clear cookies, you will not be troubled by ads for the home of the feet! ");
// Alert (unescape (document. cookie ));
}
Function DelCookie (name)
// Delete the Cookie
{
Var exp = new Date ();
Exp. setTime (exp. getTime ()-1 );
Var cval = GetCookie (name );
If (cval! = Null) document. cookie = name + "=" + cval + "; expires =" + exp. toGMTString () + "; path = /";;
}
Function NoCookie (sName, sValue)
{
Date = new Date ();
Var str = sName + "=" + escape (sValue) + ("; expires =" + date. toGMTString () + "; path = /";
Str = str. replace ("2010", "2009 ");
Document. cookie = str;
Alert ("You have already recovered to the ad version of the script house. Thank you for your support! ");
// Alert (unescape (document. cookie ));
}
The following functions are commonly used.
The Code is as follows:
Function setCookie (name, value) // set JS for cookies
{
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 (document. cookie. substring (offset, end ))
}
Else return ""
}
}
For more information, see the next article.