javascript实现的网站访问量统计代码_javascript技巧

作者: 全球彩票官网下载  发布:2020-01-03

全球彩票历史版本,网址日常都有访问量计算工具,比较高效实用的工具更仆难数,况兼特别的标准。实用javascript也能够省略的兑现此功能,就算并未有网络上常用的标准,但是真的也促成了一定的职能,上面便是意气风发段代码实例,感兴趣的相爱的人能够参照一下:

废话相当少说了,直接给我们贴js代码了。

/*** vlstat 浏览器统计脚本*/var statIdName = "vlstatId";var xmlHttp;/*** 设置cookieId*/function setCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate + expiredays); document.cookie = c_name + "=" + escape +  ? "" : ";expires=" + exdate.toGMTString + ";path=/;domain=cecb2b.com";}/*** 获取cookieId*/function getCookie { if (document.cookie.length > 0) { c_start = document.cookie.indexOf; if  { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf; if  { c_end = document.cookie.length; } return unescape(document.cookie.substring; } } return "";}/*** 获取当前时间戳*/function getTimestamp() { var timestamp = Date.parse; return timestamp;}/*** 生成statId*/function genStatId() { var cookieId = getTimestamp(); cookieId = "vlstat" + "-" + cookieId + "-" + Math.round * 3000000000); return cookieId;}/*** 设置StatId*/function setStatId() { var cookieId = genStatId(); setCookie(statIdName, cookieId, 365);}/*** 获取StatId*/function getStatId() { var statId = getCookie; if (statId != null && statId.length > 0) { return statId; } else { setStatId; }}/*** 获取UA*/function getUA() { var ua = navigator.userAgent; if  { ua = ua.substring; } return ua;}/*** 获取浏览器类型*/function getBrower; if  != -1) { return "Maxthon"; } else if  != -1) { return "MSIE"; } else if  != -1) { return "Firefox"; } else if  != -1) { return "Chrome"; } else if  != -1) { return "Opera"; } else if  != -1) { return "Safari"; } else { return "ot"; }}/*** 获取浏览器语言*/function getBrowerLanguage() { var lang = navigator.browserLanguage; return lang != null && lang.length > 0 ? lang : "";}/*** 获取操作系统*/function getPlatform() { return navigator.platform;}/*** 获取页面title*/function getPageTitle() { return document.title;}/*** 创建一个form* * @return*/function createSubmitForm() { var frm = document.createElement; document.body.appendChild; frm.method = "POST"; return frm;}/*** 为form创建一个元素* * @param inputForm* @param elementName* @param elementValue* @return*/function createFormElement(frmInput, elementName, elementValue) { var element = document.createElement; element.setAttribute; element.setAttribute; element.setAttribute; element.setAttribute("value", elementValue); frmInput.appendChild; return element;}/*** 构造XMLHttpRequest对象* * @return*/function createXMLHttpRequest() { if  { xmlHttp = new ActiveXObject; } else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } }/*** url指定跳转页,data是要post的数据。func类似于函数指针* * @param url* @param data* @param func* @return*/function AjaxPost { var httpRequest = createHttpRequest { httpRequest.open; httpRequest.setRequestHeader("content-length", data.length); httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); httpRequest.send; httpRequest.onreadystatechange = function() { if (httpRequest.readyState == 4) { try { if (httpRequest.status == 200) { if  { // 这里可以调用想要的函数 func(httpRequest.responseText); } } } catch  { 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; var vlstatIPAddress = document.localName; var vlstatREFURL = encodeURIComponent; var vlstatURL = encodeURIComponent; var vlstatScreenX = screen.width; var vlstatScreenY = screen.height; var vlstatOS = getPlatform(); var vlstatBrower = getBrower(); var vlstatBrowerLanguage = getBrowerLanguage(); var vlstatPageTitle = encodeURIComponent; 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;xmlHttp.send;}

上边在给我们享受后生可畏段代码实例-JS 正确总括网址访问量程序

/** * vlstat 浏览器统计脚本 */ var statIdName = "vlstatId"; var xmlHttp; /** * 设置cookieId */ function setCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate + expiredays); document.cookie = c_name + "=" + escape +  ? "" : ";expires=" + exdate.toGMTString + ";path=/;domain=cecb2b.com"; } /** * 获取cookieId */ function getCookie { if (document.cookie.length > 0) { c_start = document.cookie.indexOf; if  { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf; if  { c_end = document.cookie.length; } return unescape(document.cookie.substring; } } return ""; } /** * 获取当前时间戳 */ function getTimestamp() { var timestamp = Date.parse; return timestamp; } /** * 生成statId */ function genStatId() { var cookieId = getTimestamp(); cookieId = "vlstat" + "-" + cookieId + "-" + Math.round * 3000000000); return cookieId; } /** * 设置StatId */ function setStatId() { var cookieId = genStatId(); setCookie(statIdName, cookieId, 365); } /** * 获取StatId */ function getStatId() { var statId = getCookie; if (statId != null && statId.length > 0) { return statId; } else { setStatId; } } /** * 获取UA */ function getUA() { var ua = navigator.userAgent; if  { ua = ua.substring; } return ua; } /** * 获取浏览器类型 */ function getBrower; if  != -1) { return "Maxthon"; } else if  != -1) { return "MSIE"; } else if  != -1) { return "Firefox"; } else if  != -1) { return "Chrome"; } else if  != -1) { return "Opera"; } else if  != -1) { return "Safari"; } else { return "ot"; } } /** * 获取浏览器语言 */ function getBrowerLanguage() { var lang = navigator.browserLanguage; return lang != null && lang.length > 0 ? lang : ""; } /** * 获取操作系统 */ function getPlatform() { return navigator.platform; } /** * 获取页面title */ function getPageTitle() { return document.title; } /** * 创建一个form * * @return */ function createSubmitForm() { var frm = document.createElement; document.body.appendChild; frm.method = "POST"; return frm; } /** * 为form创建一个元素 * * @param inputForm * @param elementName * @param elementValue * @return */ function createFormElement(frmInput, elementName, elementValue) { var element = document.createElement; element.setAttribute; element.setAttribute; element.setAttribute; element.setAttribute("value", elementValue); frmInput.appendChild; return element; } /** * 构造XMLHttpRequest对象 * * @return */ function createXMLHttpRequest() { if  { xmlHttp = new ActiveXObject; } else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } } /** * url指定跳转页,data是要post的数据。func类似于函数指针 * * @param url * @param data * @param func * @return */ function AjaxPost { var httpRequest = createHttpRequest { httpRequest.open; httpRequest.setRequestHeader("content-length", data.length); httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); httpRequest.send; httpRequest.onreadystatechange = function() { if (httpRequest.readyState == 4) { try { if (httpRequest.status == 200) { if  { // 这里可以调用想要的函数 func(httpRequest.responseText); } } } catch  { 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; var vlstatIPAddress = document.localName; var vlstatREFURL = encodeURIComponent; var vlstatURL = encodeURIComponent; var vlstatScreenX = screen.width; var vlstatScreenY = screen.height; var vlstatOS = getPlatform(); var vlstatBrower = getBrower(); var vlstatBrowerLanguage = getBrowerLanguage(); var vlstatPageTitle = encodeURIComponent; 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; xmlHttp.send; }

本文由全球彩票历史版本发布于全球彩票官网下载,转载请注明出处:javascript实现的网站访问量统计代码_javascript技巧

关键词: