How do i change the background image in CSS at run time? I have the following background image in body and can the image be changed at run time?
body {
hei
Just set an onload function on the body:
Then do something like this in javascript:
function init() {
var someimage = 'changableBackgroudImage';
document.body.style.background = 'url(img/'+someimage+'.png) no-repeat center center'
}
You can change the 'someimage' variable to whatever you want depending on some conditions, such as the time of day or something, and that image will be set as the background image.