/beyond/javascript/article.php/3470991/So-You-Want-A-JavaScript-Clock-Huh.htm So, You Want A JavaScript Clock, Huh?

So, You Want A JavaScript Clock, Huh?

By Joe Burns

     A clock on your home page? Why, yes! I'll have one too, please. The thing at the top center of the page is what you can get here. It's a little JavaScript (not an applet) that loads into your browser, reads the time and then displays it. Pretty slick, eh? Please note that the script reads the time the browser is keeping; the time will be right in all time zones providing the viewer has his/her computer configured to give the correct time.

How To Do It...

     Oh, this one is so easy to do. First off, you need the script. I have it available to you as a simple text document. Remember, when you copy the script to copy it as is and in full. Do not attempt to change its wording or its format. Changing items to make them closer together kills the script and forbids it from working. Just copy it straightaway or save it for later. You'll notice toward the bottom of the text page that there is a </SCRIPT> command and then a small form program. Get that, too. It gives you the box that goes around the clock.

Click here to get it. (If you're using IE, click View, Source for the text.)

Is That It?

     Yeah. That's it. Just paste this pup where you want it to go on the page. If you've read over my other two JavaScript tutorials, this one will seem like a breath of fresh air. There's no changing the text or placing commands that make the script react. Just place it as if it was all one command and POOF, you get a clock.

     Oh, how I wish it was harder than that. How I love to make you suffer...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date