This is a sample and can be modified code:
<img id="Logo" src="Images/default.png" alt="KnowledgeBase" width="75%" onload="logo(this)" />
function logo(img) {
if (img.src.indexOf('default')==-1) return; // already changed
var d = new Date();
var Today = d.getDate();
var Month = d.getMonth();
var src;
if (Month === 10 && (Today >= 23 && Today <= 26)) {
src = "Images/doodles/blah1.png";
} else if (Month === 11 && (Today >= 23 && Today <= 26)) {
src = "Images/doodles/blah2.png";
} else if ((Month === 11 && Today >= 30) || (Month === 0 && Today <= 2)) {
src = "Images/doodles/blah3.png";
} else if (Month === 6 && (Today >= 3 && Today <= 5)) {
src = "Images/doodles/blah4.png";
}
img.src=src;
}
DEMO
Alternative:
<script language="javascript" type="text/javascript">
var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var thetime = new Date();
var themonth = thetime.getMonth();
document.write('<img src="image' + months[themonth] + '.gif" alt="Image of the month: ' + months[themonth] + '" />');
</script>
Alternative 3:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="banner-container" style="width:400px;height:300px;"></div>
<script>
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var total = month;
// Summer
if (total >= 6 && total <= 8)
{
document.getElementById("banner-container").style.backgroundImage = "url('images/winter.png')";
}
// Autumn
else if (total >= 9 && total <= 11)
{
document.getElementById("banner-container").style.backgroundImage="url('images/fall.png')";
}
// Winter
else if (total == 12 || total == 1 || total == 2)
{
document.getElementById("banner-container").style.backgroundImage = "url('images/winter.png')";
}
// Spring
else if (total >= 2 && total <= 6)
{
document.getElementById("banner-container").style.backgroundImage = "url('images/spring.png')";
}
else
{
document.getElementById("banner-container").style.backgroundImage = "url('images/summer.png')";
}
</script>
</body> </html>
More info: Changing image source based on date