This code makes the status bar of your web browser show a date like shown in the picture above.
doClock() calls the function doclock. The Window object supports methods for setting timers that we might use to perform a variety of functions. These methods include setTimeout() and clearTimeout(). The basic idea is to set a timeout to trigger a piece of script to occur at a particular time in the future. The general syntax is
After 1000 milliseconds windows.setTimeout() call to doClock(). The Date object provides a sophisticated set of methods for manipulating dates and times. And then it converted to string and display at status bar.
<script language="JavaScript" type="text/javascript">
function doClock() {
window.setTimeout( "doClock()", 1000 );
today = new Date();
self.status = today.toString();
}
doClock()
</script>