Status Displays Time

[Total: 0    Average: 0/5]

This files shows how to create a simple function that is called at a preset interval (1 second here – 1000 msecs). Either the recursive routine setTimeout()or the setup routine setInterval() could have been used

Head Code:

<script type="text/javascript">
var lockOut=false
function dispTime() {
  var d = new Date()
  var h = d.getHours()
  var m = d.getMinutes()
  var s = d.getSeconds()
  var ampm = (h>=12)?"PM":"AM"
  if (h>12) h-=12
  if (h==0)h=12
  if (m<10) m="0"+m
  var t = h+":"+m+" "+ampm+" and "+s+" seconds"
  if (!lockOut) defaultStatus=t
  // this could be used if the setInterval wasn't used
  //setTimeout('dispTime()',1000)
}
setInterval('dispTime()',1000)
</script>

Body Code:

<a href="http://www.greyguru.com/" onMouseOver="lockOut=true;status='Mouse Over Text';return true"
                       onMouseOut="lockOut=false;dispTime()">
MOUSE OVER ME AND WATCH THE STATUS
</a>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *