Please note: This page contains affiliate links. If you purchase from a partnership site, I may earn a commission.

Display an image according to the month name using javascript

Having content that changes dynamically (on it's own according to some criteria) is a great way to add some extra interest and diversity to your site without the added time to maintain. Scripts can automatically change various aspects of your site without you doing a thing once the script is installed.This script will display an image depending on what month it is, and will automatically update the image as soon as the month changes.

To use:
Upload GIF images named each month, January.gif, February.gif, etc.

Change the following url in the code below to the location you uploaded all your images:

Add the following code to the header of your page or site template for your site.
This code also works for Cafepress. Simply include this code either in your custom html layout header area OR, I have it in my “store description” area of my premium shop.


var d=new Date()

var month=new Array(12)

document.write(“<img src=” + month[d.getMonth()] + “.gif border=0>”)

<!– END CODE –>

Join the FREE Creative Club!
Get tutorials, free file downloads and project ideas right in your email.

1 thought on “Display an image according to the month name using javascript”

Leave a Comment

100 Directions is about trying something new, sharing creativity in every direction: Art, Travel, Food and sometimes Biz.
I work with a variety of companies to share ideas and insight about products, services and all kinds of fun, creative things to do.
I stand behind my recommendations and hope you love the things I share as much as I love sharing them with you!


Privacy Policy | Work with me


100 Directions is a JGoode Designs property. Copyright © 2011- Jen Goode. All Rights Reserved.