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

152
Views
Perform a mouse click after 5 seconds when a particular web link is the foreground tab in chrome

I want to perform a mouse click 5 seconds after a particular web page is in the foreground tab of the Chrome browser. Code for the mouse click is document.querySelector('[value="submit"]').click() and Web link is www.website.com Please guide me if this arrangement will be possible. Regards, Vicky.

@Maik Lowrey, The page is already opened in the chrome browser, say in the second tab. Now when I move to that second tab (bring it to the foreground) , I want to wait for 5 seconds and emulate a mouse click on the search button there. This is what I want to achieve. (I can't reply to your comment, so editing here)

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

0

Finally, I got this correct with this code:

if(document.referrer=="w-w-w.website.url") {
  function fireTheSubmitEvent() {
     setTimeout(fireTheSubmitEvent, 2000)
  }
  
  document.addEventListener('visibilitychange', function() {
    if (document.visibilityState === 'visible') {
      document.querySelector('[value="Search"]').click()
    }
  })
}

Thank you all.

about 4 years ago · Juan Pablo Isaza Report

0

To detect either the tab have become visible or hidden, you can use the visibilitychange event and use the visibilityState to access the state itself. Then you can use the setTimeout function to run the submit event and set the time out to 5000 miliseconds.

function fireTheSubmitEvent() {
   document.querySelector('[value="submit"]').click()
}

document.addEventListener('visibilitychange', function() {
  if (document.visibilityState === 'hidden') {
    setTimeout(fireTheSubmitEvent, 5000)
  }
})
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!