JavaScript

  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

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript

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

All rights reserved.