1. Home
  2. Computing & Technology
  3. JavaScript

Analog Clock

3. Add the Clock

clr gif
Join the Discussion

Questions? Comments?

This script has now been modified to make it completely unobtrusive so if you were using the old version then you need to delete the body script and replace the script tag in the body of your page with some simple HTML instead.

Where you attach the script into your web page depends on whether you want the clock fixed in the web page or want it to be able to move independently of the rest of the page (eg. to make it stay visible on the screen). To fix it in a particular spot just insert the following code in the body section of your page where you want the clock to appear. If you want the clock to float then use the same code just before the closing body tag and we will update the code to set its position later.

<div id="clock_a"></div>

The code that you now have will display the clock exactly as I showed in the introduction. If that is what you wanted then you are finished. If not then it is time to look at the configuration options.

Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.