Enter the clock.html text from Figure 9.12 into a new Web page, then load the page in

Question:

Enter the clock.html text from Figure 9.12 into a new Web page, then load the page in the browser to verify that it behaves as described.

As is, your clock.html page displays a single time - the clock time when the page was loaded. Modifying this page so that it displays a dynamic, running clock is surprisingly simple. Recall from Chapter 7 that the predefined setInterval function schedules the repeated execution of a function call at regular intervals. In particular, the call

setInterval('showClock()', 1000)

Will schedule the showClock function to be called every second (1,000 milliseconds). The result is that the current time is repeatedly updated in place on the screen, in effect turning the page division into a digital clock.

Modify the ONLOAD attribute of the BODY so that it executes this call to setInterval when the page loads (instead of the single call to showClock). Verify that the resulting clock "runs" in the page?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: