May 7, 2013

Display timer

Coding

<html>
<head>
<script Language="JavaScript">
var timer = null
function stop()
{
clearTimeout(timer)
}
function start()
{
var time = new Date()
var hours = time.getHours()
var minutes = time.getMinutes()
var seconds = time.getSeconds()
var clock = hours
clock += ((minutes < 10) ? ":0" : ":") + minutes
clock += ((seconds < 10) ? ":0" : ":") + seconds
document.forms[0].display.value = clock;
timer = setTimeout("start()",1000);
}
</script>
</head>
<body onload="start()" onunload="stop()">
<form>
<input type="text" name="display">
</form>
</body>
</html>

No comments:

Post a Comment

Popular Posts

Views