JS Statistics page online time script _ajax related

Source: Internet
Author: User
Per xxxxx millisecond detection is online once,
Tr_count after the user set to change the state of suspended animation (that is, not the current page activity, AFK ...)
When the page is closed, the time to send the stay

/**//* ----------------------------------------------------------------------------
* Script Name:online.js
* Last modified:2008-4-13 22:25
* Author:meyu
* Copyright (c) 2008
* Purpose: Tracking online time
* ----------------------------------------------------------------------------*/

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);};
}

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.