Dynamic CSS Switching using Javascript...
Dynamic CSS Switching using Javascript...
- Started
- Last post
- 5 Responses
- Vicentvangogh0
Try here:
- Nathan_Adams0
Why not php?
It would be easier to create a php script to choose the background, and then link to that in the css instead of a single jpg.
- neverblink0
yes, pretty simple actually.. (I'll asume it's the background image of the body you'll want to switch)
// get what day of the week it is
var d=new Date();switch(d){
case(0): // sunday
document.body.style.backgroundIm... = "url('sunday.jpg')";
break;
case(1): // monday
document.body.style.backgroundIm... = "url('monday.jpg')";
break;
// etc. for the rest of the days of the week.
}
- neverblink0
little error in above script:
var d = new Date();
d = d.getDay(); // <-- added this line