JavaScript Source: Ghi nhận thời gian người dùng đã online trên website. (Clock the visitor time visiting the page.)

Đoạn mã này giúp bạn ghi nhận lại thời gian mà người đùng đã hoạt động trên trang web của mình, về việc áp dụng có thể có nhiều thí dụ hạn chế thời gian xem một số thông tin nếu không phải là thành viên chính thức thức, ghi nhận để làm report xem thời gian người dùng duy trì trang web của mình,...


Hỗ trợ trình duyệt: Firefox, IE, Chrome, Safari, Opera




JavaScript Source:
-------------------
<html>

<head>
<title>vnlives.net</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
startday = new Date();
clockStart = startday.getTime();

function initStopwatch() {
var myTime = new Date();
return ((myTime.getTime() - clockStart) / 1000);
}

function getSecs() {
var tSecs = Math.round(initStopwatch());
var iSecs = tSecs % 60;
var iMins = Math.round((tSecs - 30) / 60);
var sSecs = "" + ((iSecs > 9) ? iSecs : "0" + iSecs);
var sMins = "" + ((iMins > 9) ? iMins : "0" + iMins);
document.forms[0].timespent.value = sMins + ":" + sSecs;
window.setTimeout('getSecs()', 1000);
}
// End -->
</script>

</head>

<body onLoad="window.setTimeout('getSecs()',1)">

<CENTER>
<FORM>
<FONT SIZE="2" FACE="Arial">Time spent here: </FONT><input size=5 name=timespent>
</FORM>
</CENTER>

</body>
</html>
-------------------













No comments:

Post a Comment