Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!