Js statistics page visit times implementation code
- 2020-03-30 02:52:22
- OfStack
Script description:
Add the following code < Body> In the area
Add the following code < Body> In the area
<SCRIPT language="JavaScript"><!--
function getCookieVal(offset)
{var endstr=document.cookie.indexOf(";",offset);if(endstr==-1)
endstr=document.cookie.length;return unescape(document.cookie.substring(offset,endstr));}function GetCookie(name)
{var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;while(i<clen)
{var j=i+alen;if(document.cookie.substring(i,j)==arg)
return getCookieVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;
}return null;}function SetCookie(name,value)
{var argv=SetCookie.arguments;var argc=SetCookie.arguments.length;var expires=(2<argc)?argv[2]:null;var path=(3<argc)?argv[3]:null;var domain=(4<argc)?argv[4]:null;var secure=(5<argc)?argv[5]:false;document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");}function ResetCounts(name)
{visits=0;SetCookie("visits",visits,expdate,"/",null,false);location.reload();}
//-->
</SCRIPT>
<SCRIPT language="JavaScript"><!--
var expdate=new Date();
var visits;//The following COOKIES are set for 1 year. Please set the time arbitrarily by yourself..
expdate.setTime(expdate.getTime()+(24*60*60*1000*365));
if(!(visits=GetCookie("visits")))
visits=0;visits++;SetCookie("visits",visits,expdate,"/",null,false);//The following information can be displayed using standard HTML syntax, set yourself.
document.write(" You have come to this page "+"<FONT COLOR=red>"+visits+"</FONT>"+" Times! ");if(visits==1)//Visit 1 information display
document.write("<br>"+" Welcome to this site, what do you think of the content of this site? ");if(visits==2)//Visit 2 times of information display, the following analogy, their random increase.
document.write("<br>"+" We shall be glad to see you again ! Come back often from now on! Welcome to subscribe to our mailing list. ");if(visits==3)
document.write("<br>"+" Regular guest, how about a post in the forum of this station? ");if(visits==4)
document.write("<br>"+" You nuts !");if(visits>=5)
document.write("<br>"+" Crazy guy ! I really like you very much. ");
//-->
</SCRIPT>