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

392
Visualizações
How to close an open window after the user has searched something in the open window(using JavaScript)?

I'm currently building a video game on the web, it's a millionaire. I came up with the idea that as one of the help, I would enable users to use google for 20 seconds. I managed to open a window with a search engine, but after 20 seconds I want to close it, this is not possible if the user has searched something.

newWindow=window.open('https://google.com','mywindow', 'width=375px, height=400px, top=200px')
setTimeout(() =>{
    newWindow.close()
},22000)

I also watched this tutorial: https://www.youtube.com/watch?v=2Qu8mwQizbM

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Closing another window from JS should not be possible, as your code only has control of your tab. One way you could do what you're trying to do is to create an <iframe> then remove it after 20 seconds with setTimeout().

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