Relógio na barra de status
- Para que esse código funcione é necessário que você coloque essa tag:
onLoad="startclock()"
dentro do <body>.
Exemplo:
<body onLoad="startclock()">
- Cole o código abaixo dentro das tags
<body> </body>
.
<script language="JavaScript"> var timerID = null; var timerRunning = false; function startclock () { stopclock(); time(); } function stopclock () { if(timerRunning) clearTimeout(timerID); timerRunning = false; } function time() { var now = new Date(); var ampm = (now.getHours() >= 12) ? " P.M." : " A.M." var hours = now.getHours(); hours = ((hours > 12) ? hours - 12 : hours); var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes(); var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds(); var Time=(hours + minutes + seconds + " " + ampm ); window.status=Time; timerID = setTimeout("time()",1000); timerRunning = true; } function clearStatus() { if(timerRunning) clearTimeout(timerID); timerRunning = false; window.status=""; } </script>