JavaScript Change Image on Specified Date

 

Version 1 - This script will change an image on or after a specified date.

 

Version 2 - The script will change an image depending on the seasons. ("Alt" image tag displayed only for demo purposes)

 

Example 1



 

Script Source

Version 1

<script type="text/javascript">
// ©2009 www.wizzardweb.co.uk
var Date = new Date();
var Today = Date.getDate();

if(Today < 16)
{
document.write('<img src="http://www.imagelocation_here" alt="Image title " width="117" height="100" />');
}
else
{
document.write('<img src="http://www.imagelocation_here" alt="image title " width="117" height="100" />');
}
</script>

 

Version 2

<script type="text/javascript">
// ©2009 www.wizzardweb.co.uk
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var total = month;

// Summer
if (total >=6 && total <= 8)
{
document.write('<img src="" alt="It is now Summer" width="117" height="100" />');
}
// Autumn
else if (total >=9 && total <= 11)
{
document.write('<img src="" alt="It is now Autumn" />');
}
// Winter
else if (total ==12 || total == 1 || total == 2)
{
document.write('<img src="" alt="It is now Winter" />');
}
// Spring
else if (total >=2 && total <= 6)
{
document.write('<img src="" alt="It is now Spring" />');
}

else
{
document.write("<b><br>Error!</b>");
}
</script>

 

Please let me know if this script was helpful to you.

[rating]