Following program can be used to Stopwatch on the webpage like:
<html> <head> <title>Untitled Document</title> <script language="javascript" type="text/javascript"> var timerID = null; var timerRunning = false; var now = new Date(); var hours = 0; var minutes =0; var seconds =0 function stopclock () { if(timerRunning) clearTimeout(timerID); timerRunning = false; } function showtime () { if(seconds>=59) { seconds=0; minutes=minutes+1; } else { seconds=1+seconds; } if(minutes>=59) { minutes=0; hours=hours+1; } var timeValue =zeroPad(hours,2)+":"+zeroPad(minutes,2)+":"+zeroPad(seconds,2); document.getElementById("timeDisplay").innerHTML=timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } function startclock() { stopclock(); showtime(); } // End --> function zeroPad(num,count) { var numZeropad = num + ''; while(numZeropad.length < count) { numZeropad = "0" + numZeropad; } return numZeropad; } </script> </head> <body onload="startclock();"> <h2 style="color: #000000; margin: left;"> Processing Time :: <span id="timeDisplay"></span> </body> </html>