home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magazyn WWW 1999 July
/
www_07_1999.iso
/
prez
/
amiga
/
KidHTML1_25.lha
/
KidHTML1.25
/
Script
/
timeonpage.js
< prev
next >
Wrap
Text File
|
1998-08-25
|
1KB
|
48 lines
<!-- THREE STEPS TO INSTALL TIME ON PAGE (CLOCK):
1. Paste the coding into the HEAD of your HTML document
2. Copy the onLoad event handler into the BODY tag
3. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available online from -->
<!-- The JavaScript Source!! http://javascriptsource.com -->
<!-- Begin
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);
}
// End -->
</script>
<!-- STEP TWO: Add this onLoad event handler into the BODY tag -->
<BODY onLoad="window.setTimeout('getSecs()',1)">
<!-- STEP THREE: Put this code into the BODY of your HTML document -->
<CENTER>
<FORM>
<input size=5 name=timespent>
</FORM>
</CENTER>
<!-- Script Size: 1.29 KB -->