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

399
Views
How can you delay an <a> link from loading until after the element animates out of the viewport?

I styled some elements with :active and :hover pseudo-selectors, including a "button press" type animation that also triggers animations that slide the elements out of the viewport.

I'm trying to make a really smooth UX and want to delay the hyperlinked content from loading until after these animations finish.

How can you accomplish this load delay with HTML/CSS/JS?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use the JavaScript setTimeout function to delay your redirect.

For example, if you have a link as below, call the function on link click:

<a href="javascript:void" onclick="onBtnClickHandle()">Click Here</a>

Create a JavaScript function and add the delay using the setTimeout function:

  function onBtnClickHandle(){
    setTimeout(function(){ 
    window.location="https://www.google.com/"
 }, 3000);
}

You can set the timeout value as per your animation timing.

Demo:

  function onBtnClickHandle(){
        setTimeout(function(){ 
        window.location="https://www.google.com/"
     }, 3000);
    }
<a href="javascript:void" onclick="onBtnClickHandle()">Click Here</a>

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!