Běžící čas pobytu na stránce -
zdrojový kód
<html>
<head>
<title>Java Script ze stránky - www.jaknaweb.com</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
</head>
<body onload="window.setTimeout('getSecs()',1)">
<script>
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(".")) + " secs.";
document.forms[0].timespent.value = mySecs1
window.setTimeout('getSecs()',1000);
}
</script>
<form>
<div align="center"><center><p>Už jsi na této stránce:<br>
<input name="timespent" size="9"
style="color: rgb(0,255,0); background-color: rgb(0,0,0); font-family: LiquidCrystal; font-size: 15; font-weight: bold; text-align: center;">
</p>
</center></div>
</form>
</Body>
</HTML>