JS Accurate statistics site access to the example code _javascript tips

Source: Internet
Author: User
Tags setcookie
Copy Code code as follows:

/**
* Vlstat Browser Statistics 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.indexOf (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 "";
}
/**
* Get current time stamp
*/
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 > 250) {
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 the operating system
*/
function GetPlatform () {
return navigator.platform;
}
/**
* Get page title
*/
function Getpagetitle () {
return 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 the form
*
* @param inputform
* @param elementname
* @param elementvalue
* @return
*/
function Createformelement (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;
}
/**
* Construct XMLHttpRequest Object
*
* @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 post. Func similar to function pointers
*
* @param URL
* @param data
* @param func
* @return
*/
function ajaxpost (URL, data, func) {
var HttpRequest = 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 (Httprequest.status = = 200) {
if (func) {
Here you can call the desired function
Func (Httprequest.responsetext);
}
}
catch (e) {
Alert ("Error xmlhttprequest!");
}
}
}
} else {
Alert ("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=" + vlstatbrowerlanguage
+ "&title=" + vlstatpagetitle + "&ch=" + Vlstatch + "&ch1=" + vlstatCH1 + "&ch2=" + vlstatCH2
+ "&ch3=" + vlstatCH3;
var Urlgo = vlstataction + "?" + P;
Createxmlhttprequest ();
Xmlhttp.open (' Get ', Urlgo);
Xmlhttp.send (NULL);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.