What I’m trying to do is change a landing page image based on the month and day. Trouble is when I implement this code I get an error, here’s the code:
function kblogo() {
var d = new Date();
var Today = d.getDate();
var Month = d.getMonth();
var logoSrc;
if (Month == 10 && (Today >= 23 && Today <= 26)) {
logoSrc = "Images/doodles/KBThanksgiving.png";
} else if (Month == 11 && (Today >= 23 && Today <= 26)) {
logoSrc = "Images/doodles/KBHolidays.png";
} else if ((Month == 11 && Today >= 30) || (Month == 0 && Today <= 2)) {
logoSrc = "Images/doodles/KBNewYear.png";
} else if (Month == 6 && (Today >= 3 && Today <= 5)) {
logoSrc = "Images/doodles/KBJuly4.png";
} else {
logoSrc = "Images/KB.png";
}
document.getElementById("kbLogo").src = logoSrc;
}
Just changed the code to this I’ll be testing it shortly. Any idea’s let me know.
I’ve run it through some different validators and found different things and fixed them but it’s as fixed as I have gotten it and it still crashes IE and FF when I implement it.
<img id="Logo" src="Images/default.png" alt="KnowledgeBase" width="75%" onload="logo()" />
Above is the requested img tag
Your logo function is looping – also no need to load default if default is already loaded
DEMO