Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
How to make a smooth background transition when image hasn't loaded

I want the background of my website to be images pulled from the internet, a new one every 5 seconds, I could make this work, but my screen flashes white every time a new image appears because it needs to load in. Is it possible to wait until the image loaded in and then show it?

Here is my current function to change the background to a random image from a list:

function newBackground() {
  var url = urls[Math.floor(Math.random() * urls.length)];
  body.style.backgroundImage = "url('" + url + "')";
}

This was fixed by the comment from yozibak, thank you

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda