<html> <head> <title>Java Script определяющий время нахождения на страничке.</title> <script language="JavaScript"> <!--// 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> </head> <body onload="window.setTimeout('getSecs()',1)"> <form><div>Вы на странице <input type="text" size="20" name="timespent" onfocus="this.blur()" style="font-family: sans-serif; text-align: left; background-color: rgb(0,0,0); color: rgb(255,255,0); border: thin"></div></form> </body> </html>
|