js統(tǒng)計網(wǎng)頁在線時間的腳本
更新時間:2008年04月24日 19:35:57 作者:
分析用戶行為時,某網(wǎng)頁停留時間可能會是個可參考的數(shù)據(jù)
由后臺分析函數(shù)取一個合理值作為在線時間
每xxxxx毫秒檢測一次是否在線,
TR_COUNT次之后設(shè)定改用戶為假死狀態(tài)(即不在當(dāng)前頁面活動,afk..)
當(dāng)頁面關(guān)閉時把停留時間送出,
/**//* ----------------------------------------------------------------------------
* Script Name: online.js
* Last Modified: 2008-4-13 22:25
* Author: meyu
* Copyright (c) 2008
* Purpose: 跟蹤在線時間
* ----------------------------------------------------------------------------*/
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)前頁面活動,afk..)
當(dāng)頁面關(guān)閉時把停留時間送出,
/**//* ----------------------------------------------------------------------------
* Script Name: online.js
* Last Modified: 2008-4-13 22:25
* Author: meyu
* Copyright (c) 2008
* Purpose: 跟蹤在線時間
* ----------------------------------------------------------------------------*/
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)計,區(qū)分英漢
- js cookies實現(xiàn)簡單統(tǒng)計訪問次數(shù)
- javascript實現(xiàn)的柱狀統(tǒng)計圖表
- javascript 利用Image對象實現(xiàn)的埋點(某處的點擊數(shù))統(tǒng)計
- Highcharts 非常實用的Javascript統(tǒng)計圖demo示例
- JS 精確統(tǒng)計網(wǎng)站訪問量的實例代碼
- JS實現(xiàn)在線統(tǒng)計一個頁面內(nèi)鼠標(biāo)點擊次數(shù)的方法
- nodejs實現(xiàn)遍歷文件夾并統(tǒng)計文件大小
- JavaScript實現(xiàn)網(wǎng)站訪問次數(shù)統(tǒng)計代碼
- JS使用單鏈表統(tǒng)計英語單詞出現(xiàn)次數(shù)
相關(guān)文章
菜鳥蔡之Ajax復(fù)習(xí)第二篇(JQuery中的load()方法實現(xiàn)Ajax功能)
在上一篇博客中寫到的是在傳統(tǒng)的Javascript中使用XMLHttpRequest對象異步加載數(shù)據(jù)的,唉,童鞋.......看到那些代碼是不是有點頭疼啊!呵呵......2012-11-11
AJAX初級應(yīng)用-RSS無刷新聚合器的代碼與下載
AJAX初級應(yīng)用-RSS無刷新聚合器的代碼與下載...2007-03-03

