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

391
Views
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 answers
Answer question

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 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!