1. Home
  2. Computing & Technology
  3. JavaScript

Day of Week

1. Introduction and Sample

clr gif
Join the Discussion

Questions? Comments?

One way that you can have your web page to changed when a visitor returns a day or two later is to display a different image on your page depending on the day of the week. How do we do that? Well by using Javascript to grab the day from your visitors computer and then selecting one of serveral images to display based on that day.

This Javascript code uses seven images to represent the different days of the week. You can use whatever images you like, the only limitation is that all of the images will need to be the same size.

I have used simple images that contain just the name of the particular day. Here is what the script produces on this day of the week using my images.

To add this to your page you first need to create the images.

1 | 2 | 3 | 4
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.