Time On Page

[Total: 0    Average: 0/5]

This shows how to have a form textbox keep track of the time spent on a page.

Body Code:

<font size=+1>Timer</font><hr>
A very simple timer that will tell how much time is spent on one page.<p>
<CENTER><form name=exf1>
Time spent on this page: 
<input size=9 name=timespent>

startday = new Date();
clockStart = startday.getTime();

function initStopwatch() 
 var myTime = new Date(); 
        var timeNow = myTime.getTime();  
        var timeDiff = timeNow - clockStart; 
        this.diffSecs = timeDiff/1000; 

function getSecs() 
        var mySecs = initStopwatch(); 
        var mySecs1 = ""+mySecs; 
        mySecs1= mySecs1.substring(0,mySecs1.indexOf(".")) + " secs."; 
        document.exf1.timespent.value = mySecs1 

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *