在线统计网站html代码,统计网页在线时间的js代码

例子,每xxxxx毫秒检测一次是否在线,TR_COUNT次之后设定改用户为假死状态(即不在当前页面活动,afk..)

当页面关闭时把停留时间送出。

代码,统计网页的在线时间。

复制代码 代码示例:

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.οnunlοad=function()...{TR_x.sendData('&flush_count='+TR_COUNT);};

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值