Таймер показывает время, проведенное на сайте, в секундах:
Код таймера:
Code
<!-- saved from url=(0049)http://www.superbest.com/javascript/clocksite.htm -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta name="description"
content="Java Script определяющий время нахождения на страничке.">
<meta name="KEYWORDS"
content="Free JavaScript, E-Mail gifs, Front Page server, продукты, web site hosting">
<meta name="ROBOTS" content="ALL">
<meta name="Microsoft Border" content="b, default">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title>Ваше время на страничке</title>
</head>
<body bgcolor="#FFFFFF" text="#0000FF" onload="window.setTimeout('getSecs()',1)">
<div align="center"><center>
<table border="1" cellspacing="1" bgcolor="#000000" bordercolor="#FFFFFF"
bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="3">
<tr>
<td valign="top"><script language="JavaScript"><!--
function person_in() {
enter=new Date();
}
function person_out() {
exit=new Date();
time_dif=(exit.getTime()-enter.getTime())/1000;
time_dif=Math.round(time_dif);
alert ("You've only been here for: " + time_dif + " seconds!")
}
startday = new Date();
clockStart = startday.getTime();
function initStopwatch() {
var myTime = new Date();
var timeNow = myTime.getTime();
var timeDiff = timeNow - clockStart;
this.diffSecs = timeDiff/1000;
return(this.diffSecs); }
function getSecs() {
var mySecs = initStopwatch();
var mySecs1 = ""+mySecs;
mySecs1= mySecs1.substring(0,mySecs1.indexOf(".")) + " сек.";
document.forms[0].timespent.value = mySecs1
window.setTimeout('getSecs()',1000); }
// --></script><form>
<div align="center"><center>
<font color="#80FF00" face="MS Sans Serif" size="1">Вы
находитесь на этой странице уже:<br>
<br>
</font><input type="text" size="20" name="timespent" onfocus="this.blur()"
style="font-family: sans-serif; text-align: center; font-size: 8pt; background-color: rgb(0,0,0); color: rgb(255,255,0); border: thin"></p>
</center></div>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>