Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> JavaScript >> Snippet

Time at site


< html >
< head >
< script >
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);
}
</ script >

</ head >

< body Background = .. / graphics / grayback.jpg onLoad = "window.setTimeout('getSecs()',1)" >
< center >< BR >< BR >< BR >
< FORM >
< input size = 5 name = timespent >
</ FORM >

</ BODY >
</ html >

//Thanks to David Pye for his JavaScript Vault contribution.