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

128
Views
adding setTimeout to close a preloader

I'm not so good at javascript and I'm trying to add setTimeout to close my preloader after a certain time, but it doesn't work. Can someone help me? Thank you so much.

document.onreadystatechange = function () {
    var e = document.readyState;
    "interactive" == e
        ? ((document.body.style.overflow = "hidden"), (document.getElementById("contents").style.visibility = "hidden"))
        : "complete" == e &&
          setTimeout(function () {
              document.getElementById("interactive"), (document.body.style.overflow = "auto"), (document.getElementById("load").style.visibility = "hidden"), (document.getElementById("contents").style.visibility = "visible");
              
          },
           1e3);
           setTimeout(e, 3500);
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I understood correctly what you are trying to achieve , this is what you are looking for.

window.addEventListener('load', () => { // wait to load the page
  setTimeout(() => {
    document.querySelector('.loader').style.display = 'none' // hide the loader after 3.5 seconds
    console.log('loaded')
  }, 3500)
})
<div class="loader">Loading...</div>

about 4 years ago · Juan Pablo Isaza Report
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!