js統(tǒng)計(jì)網(wǎng)頁在線時(shí)間的腳本
更新時(shí)間:2008年04月24日 19:35:57 作者:
分析用戶行為時(shí),某網(wǎng)頁停留時(shí)間可能會(huì)是個(gè)可參考的數(shù)據(jù)
由后臺(tái)分析函數(shù)取一個(gè)合理值作為在線時(shí)間
每xxxxx毫秒檢測(cè)一次是否在線,
TR_COUNT次之后設(shè)定改用戶為假死狀態(tài)(即不在當(dāng)前頁面活動(dòng),afk..)
當(dāng)頁面關(guān)閉時(shí)把停留時(shí)間送出,
/**//* ----------------------------------------------------------------------------
* Script Name: online.js
* Last Modified: 2008-4-13 22:25
* Author: meyu
* Copyright (c) 2008
* Purpose: 跟蹤在線時(shí)間
* ----------------------------------------------------------------------------*/
function TR_XMLHttpObject(url)...{
this.XMLHttp=null;
this.url=url;
this.init=function()...{
if(window.XMLHttpRequest)...{
this.XMLHttp=new XMLHttpRequest();
}else if(window.ActiveXObject)...{
this.XMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
};
this.init();
this.sendData=function(param)...{
with(this.XMLHttp)...{
open('GET',this.url+(param||''),true);
send(null);
}
};
}
if(/flag=flush/i.test(window.location.search))...{
var TR_COUNT=0;
var TR_x=new TR_XMLHttpObject(window.location.href.replace(/&?(?:flush_count=)(d+)/i,
function(a,d)...{
TR_COUNT=parseInt(d);
return "";
})
);
function send()...{
TR_COUNT++;
if(TR_COUNT < 120)...{
TR_x.sendData('&flush_count='+TR_COUNT);
}
}
window.setInterval(send,30000);
window.onunload=function()...{TR_x.sendData('&flush_count='+TR_COUNT);};
}
TR_COUNT次之后設(shè)定改用戶為假死狀態(tài)(即不在當(dāng)前頁面活動(dòng),afk..)
當(dāng)頁面關(guān)閉時(shí)把停留時(shí)間送出,
/**//* ----------------------------------------------------------------------------
* Script Name: online.js
* Last Modified: 2008-4-13 22:25
* Author: meyu
* Copyright (c) 2008
* Purpose: 跟蹤在線時(shí)間
* ----------------------------------------------------------------------------*/
function TR_XMLHttpObject(url)...{
this.XMLHttp=null;
this.url=url;
this.init=function()...{
if(window.XMLHttpRequest)...{
this.XMLHttp=new XMLHttpRequest();
}else if(window.ActiveXObject)...{
this.XMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
};
this.init();
this.sendData=function(param)...{
with(this.XMLHttp)...{
open('GET',this.url+(param||''),true);
send(null);
}
};
}
if(/flag=flush/i.test(window.location.search))...{
var TR_COUNT=0;
var TR_x=new TR_XMLHttpObject(window.location.href.replace(/&?(?:flush_count=)(d+)/i,
function(a,d)...{
TR_COUNT=parseInt(d);
return "";
})
);
function send()...{
TR_COUNT++;
if(TR_COUNT < 120)...{
TR_x.sendData('&flush_count='+TR_COUNT);
}
}
window.setInterval(send,30000);
window.onunload=function()...{TR_x.sendData('&flush_count='+TR_COUNT);};
}
您可能感興趣的文章:
- js 字?jǐn)?shù)統(tǒng)計(jì),區(qū)分英漢
- js cookies實(shí)現(xiàn)簡(jiǎn)單統(tǒng)計(jì)訪問次數(shù)
- javascript實(shí)現(xiàn)的柱狀統(tǒng)計(jì)圖表
- javascript 利用Image對(duì)象實(shí)現(xiàn)的埋點(diǎn)(某處的點(diǎn)擊數(shù))統(tǒng)計(jì)
- Highcharts 非常實(shí)用的Javascript統(tǒng)計(jì)圖demo示例
- JS 精確統(tǒng)計(jì)網(wǎng)站訪問量的實(shí)例代碼
- JS實(shí)現(xiàn)在線統(tǒng)計(jì)一個(gè)頁面內(nèi)鼠標(biāo)點(diǎn)擊次數(shù)的方法
- nodejs實(shí)現(xiàn)遍歷文件夾并統(tǒng)計(jì)文件大小
- JavaScript實(shí)現(xiàn)網(wǎng)站訪問次數(shù)統(tǒng)計(jì)代碼
- JS使用單鏈表統(tǒng)計(jì)英語單詞出現(xiàn)次數(shù)
相關(guān)文章
jQuery Validator驗(yàn)證Ajax提交表單的方法和Ajax傳參的方法
這篇文章主要介紹了jQuery Validator驗(yàn)證Ajax提交表單的方法和Ajax傳參的方法,在文中還給大家提到了jquery .ajax提交表單的寫法,具體實(shí)例代碼大家參考下本文2017-08-08AJAX初體驗(yàn)之實(shí)戰(zhàn)篇——打造博客無刷新搜索
AJAX初體驗(yàn)之實(shí)戰(zhàn)篇——打造博客無刷新搜索...2006-08-08ajax實(shí)現(xiàn)文件異步上傳并回顯文件相關(guān)信息功能示例
這篇文章主要介紹了ajax實(shí)現(xiàn)文件異步上傳并回顯文件相關(guān)信息功能,結(jié)合實(shí)例形式分析了基于jQuery $.ajax方法的文件異步上傳以及后臺(tái)java程序?qū)ξ募畔⒌淖x取與顯示相關(guān)操作技巧,需要的朋友可以參考下2018-06-06Jquery基于Ajax方法自定義無刷新提交表單Form實(shí)例
這篇文章主要介紹了Jquery基于Ajax方法自定義無刷新提交表單Form的方法,結(jié)合實(shí)例詳細(xì)分析了Ajax無刷新提交表單的完整實(shí)現(xiàn)過程,并總結(jié)了使用中的注意事項(xiàng),具有很好的借鑒價(jià)值,需要的朋友可以參考下2014-11-11AjaxFileUpload結(jié)合Struts2實(shí)現(xiàn)多文件上傳(動(dòng)態(tài)添加文件上傳框)
本文是腳本之家小編給大家分享的AjaxFileUpload結(jié)合Struts2實(shí)現(xiàn)多文件上傳功能,如果項(xiàng)目需求是不確定多少個(gè)文件,我們需要?jiǎng)討B(tài)的添加文件上傳框,具體實(shí)現(xiàn)代碼大家參考下本文2017-09-09