0
So I wanted to make a bg-image if it changes dynamically the same in this example: http://www.goesenlinea.com/agus/
Background changes every 5 seconds.
Does anyone know how ?
0
So I wanted to make a bg-image if it changes dynamically the same in this example: http://www.goesenlinea.com/agus/
Background changes every 5 seconds.
Does anyone know how ?
2
You can do it via Javascript with a timer running 5 in 5 sec. See example:
// initial call, or just call refresh directly
setInterval(AsyncTrocaImg, 5000);
function AsyncTrocaImg() {
$.post(base + "Home/GetNewImg", {}, function (URL) {
$('body').css('background-image', 'url('+URL+')');
}).fail(function () {
console.log("error");
})
}
But be careful with the images, so your site doesn’t get "heavy".
I would also have some other forms even simple, but this is the way I would do.
Also see if these links help you:
Browser other questions tagged javascript html css background
You are not signed in. Login or sign up in order to post.