There are many sites will add a traffic statistics function, in fact, the code is very simple, all JS written, and the code is not much
This function explains that, every visit, the amount of traffic written on the page will be increased by one, and so on, the following to share with you a piece of code to implement this function
<script language=javascript><!--varCaution =falsefunctionSetcookie (name, value, expires, path, domain, secure) {varCurcookie = name + "=" + Escape (value) +((expires)? "; Expires= "+ expires.togmtstring ():" ") +(PATH)? "; Path= "+ Path:" ") +(domain)? "; domain= "+ domain:" ") +(Secure)? "; Secure ":" ")if(!caution | | (name + "=" + Escape (value)). Length <= 4000) Document.cookie=CurcookieElseif(Confirm ("Cookie exceeds 4KB and would be cut!")) Document.cookie=Curcookie}functionGetCookie (name) {varprefix = name + "="varCookiestartindex =document.cookie.indexOf (prefix)if(Cookiestartindex = =-1)return NULLvarCookieendindex = Document.cookie.indexOf (";", Cookiestartindex +prefix.length)if(Cookieendindex = =-1) Cookieendindex=Document.cookie.lengthreturnUnescape (document.cookie.substring (Cookiestartindex +prefix.length, Cookieendindex)}functionDeletecookie (name, path, domain) {if(GetCookie (name)) {Document.cookie= name + "=" +(PATH)? "; Path= "+ Path:" ") +(domain)? "; domain= "+ domain:" ") +"; Expires=thu, 01-jan-70 00:00:01 GMT "}}functionfixdate (date) {varBase =NewDate (0)varSkew =base.gettime ()if(Skew > 0) Date.settime (Date.gettime ()-skew)}varnow =NewDate () fixdate (now) Now.settime (Now.gettime ()+ 365 * 24 * 60 * 60 * 1000)varvisits = GetCookie ("Counter")if(!visits) Visits= 1Elsevisits= parseint (visits) + 1Setcookie ("Counter", visits, now) document.write ("You are the first" + Visits + "bit to access this topic! ")// -</script>
Just need this piece of code on it, put it where you want to put it, the site will have this function, look at the implementation of the
Since I put this function, a total of 3 visits, so the above is shown to the 3rd place, interested also to try it, like can keep their own
How to achieve the function of statistic traffic in the website