Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda