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

155
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
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