Web sites generally have access statistics tools, the more efficient and practical tools are diverse and very accurate. Practical JavaScript can also be simple to implement this function, although not commonly used on the network of precision, but did implement a certain function, the following is a code example, interested friends can refer to:
<script type= "Text/javascript" >/** * Vlstat Browser Statistic script * * var statidname = "Vlstatid";
var xmlHttp;
/** * Set Cookieid/function Setcookie (c_name, value, expiredays) {var exdate = new Date ();
Exdate.setdate (exdate.getdate () + expiredays); Document.cookie = c_name + "=" + Escape (value) + ((expiredays = null)?
"':"; expires= "+ exdate.togmtstring ()) +";p ath=/;d omain=cecb2b.com ";} /** * Get Cookieid/function GetCookie (c_name) {if (Document.cookie.length > 0) {c_start = Document.cookie.inde
XOf (c_name + "=");
if (C_start!=-1) {C_start = C_start + c_name.length + 1;
C_end = Document.cookie.indexOf (";", C_start);
if (c_end = = 1) {c_end = Document.cookie.length;
Return unescape (document.cookie.substring (C_start, c_end));
} return "";}
/** * Gets the current timestamp/function Gettimestamp () {var timestamp = Date.parse (new Date ());
return timestamp; /** * Generate Statid/function Genstatid () {var Cookieid = GettimestAMP ();
Cookieid = "Vlstat" + "-" + Cookieid + "-" + Math.Round (math.random () * 3000000000);
return Cookieid;
/** * Set Statid/function Setstatid () {var cookieid = Genstatid ();
Setcookie (Statidname, Cookieid, 365);
/** * Get Statid/function Getstatid () {var statid = GetCookie (statidname);
if (Statid!= null && statid.length > 0) {return statid;
else {Setstatid ();
return Getstatid ();
}/** * Get UA/function Getua () {var ua = navigator.useragent;
if (Ua.length >) {ua = ua.substring (0, 250);
Return UA;
/** * Get Browser type/function Getbrower () {var ua = Getua ();
if (Ua.indexof ("Maxthon")!=-1) {return "Maxthon";
else if (Ua.indexof ("MSIE")!=-1) {return "MSIE";
else if (Ua.indexof ("Firefox")!=-1) {return "Firefox";
else if (Ua.indexof ("Chrome")!=-1) {return "Chrome";
else if (Ua.indexof ("opera")!=-1) {return "opera";
else if (Ua.indexof ("Safari")!=-1) { return "Safari";
else {return ' OT ';
}/** * Get browser language/function Getbrowerlanguage () {var lang = navigator.browserlanguage; return lang!= null && lang.length > 0?
Lang: "";} /** * Get OS/function GetPlatform () {return navigator.platform;}/** * Get page title/function Getpagetitle () {RET
Urn Document.title;
/** * Create a form * * @return/function Createsubmitform () {var frm = document.createelement ("form");
Document.body.appendChild (frm);
Frm.method = "POST";
return frm; /** * Create an element for form * * @param inputform * @param elementname * @param elementvalue * @return/function Createformeleme
NT (Frminput, ElementName, elementvalue) {var element = document.createelement ("input");
Element.setattribute ("id", elementname);
Element.setattribute ("name", elementname);
Element.setattribute ("type", "hidden");
Element.setattribute ("value", elementvalue);
Frminput.appendchild (Element);
return element; }/** * Constructs XMLHttpRequest objects * *@return */function Createxmlhttprequest () {if (window).
ActiveXObject) {xmlHttp = new ActiveXObject (' microsoft.xmlhttp '); else if (window.
XMLHttpRequest) {xmlHttp = new XMLHttpRequest (); The/** * URL specifies the jump page, and data is the one to post. Func similar to function pointer * * @param URL * @param data * @param func * @return/function ajaxpost (URL, data, func) {var httpreques
t = createhttprequest ();
if (HttpRequest) {Httprequest.open ("POST", url, True);
Httprequest.setrequestheader ("Content-length", data.length);
Httprequest.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Httprequest.send (data); Httprequest.onreadystatechange = function () {if (httprequest.readystate = 4) {try {if (httpreq)
Uest.status = =/{if (func) {///Here you can call the desired function func (httprequest.responsetext);
catch (E) {alert ("Error xmlhttprequest!"); else {Ale}}}}RT ("Error initializing xmlhttprequest!");
} function Vlstatinitle (Vlch, Vlch1, VLCH2, Vlch3) {var p; var vlstatch = Vlch!= null && vlch.length > 0?
Vlch: ""; var vlstatCH1 = vlch1!= null && vlch1.length > 0?
Vlch1: ""; var vlstatCH2 = vlch2!= null && vlch2.length > 0?
VLCH2: ""; var vlstatCH3 = Vlch3!= null && vlch3.length > 0?
VLCH3: "";
var Vlstatcookieid = Getstatid ();
var Vlstatua = encodeURIComponent (Getua ());
var vlstatipaddress = Document.localname;
var vlstatrefurl = encodeURIComponent (document.referrer); var vlstaturl = encodeuricomponent (document.
URL);
var vlstatscreenx = screen.width;
var vlstatscreeny = screen.height;
var vlstatos = GetPlatform ();
var vlstatbrower = Getbrower ();
var vlstatbrowerlanguage = Getbrowerlanguage ();
var vlstatpagetitle = encodeURIComponent (Getpagetitle ());
var vlstataction = "index.php"; p = "Cookieid=" + Vlstatcookieid + "&ua=" + Vlstatua + "&Ip= "+ vlstatipaddress +" &refurl= "+ Vlstatrefurl +" &url= "+ Vlstaturl +" &screenx= "+ Vlstatscreenx + "&screeny=" + Vlstatscreeny + "&os=" + Vlstatos + "&brower=" + vlstatbrower + "&browerlang=" + vlst Atbrowerlanguage + "&title=" + vlstatpagetitle + "&ch=" + Vlstatch + "&ch1=" + vlstatCH1 + "&ch2=" +
VlstatCH2 + "&ch3=" + vlstatCH3;
var Urlgo = vlstataction + "?" + P;
Createxmlhttprequest ();
Xmlhttp.open (' Get ', Urlgo);
Xmlhttp.send (NULL); } </script>
Hopefully this article will help you learn about JavaScript programming.