Copy codeThe Code is as follows:
<Script type = "text/javascript">
If (getCookie ("num ")){
Var nn = parseInt (getCookie ("num "));
SetCookie ("num", ++ nn );
} Else {
SetCookie ("num", 1 );
}
Function getCookie (name ){
Var str = document. cookie. split (";");
For (I = 0; I <str. length; I ++ ){
Var str2 = str [I]. split ("= ")
If (str2 [0]. replace (/\ s (. *) \ s/, "$1") = name ){
Return str2 [1];
}
}
}
Function setCookie (name, value ){
Var Days = 30;
Var exp = new Date ();
Exp. setTime (exp. getTime () + Days x 24x60*60*1000 );
Document. cookie = name + "=" + escape (value) + "; expires" + exp. toGMTString ();
}
Alert ("you are the" + getCookie ("num") + "");
/* String. prototype. Trim = function (){
Return this. replace (/\ s (. *) \ s/, "$1 ");
}
String. prototype. alert2 = function (str ){
Alert ("I am alert2 !!! The actual content of hahaha is: "+ str );
}
Var aa = "";
Aa. alert ("liugang ");*/
</Script>