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

192
Views
window.closed is sometimes true although tab is not closed

I have an Angular app that opens a link to an external site in a new tab when I click a button and then checks in an interval, if the tab is closed and when it is closed do stuff.

This works sometimes, but sometimes this doesn't work. When I check if the tab is closed with window.closed it is sometimes true, although the tab is not closed.

This issue appeared about a week or two ago and hasn't happened before then. I made no changes at all (the app is running for 2 months on a server without any code changes or anything). I also tried an old version of Chrome and another PC and the issue is still there.

The code looks like this

webUrl = "https://www.google.com"
this.otherWindow = window.open(webUrl, 'otherWindowCtx');
const interval = setInterval(async () => {
   if (this.otherWindow.closed) {
      doStuff();
      clearInterval(interval );
   }
}, 5000);

The thing is, when webUrl is the link to Google (or almost any other site) it works as expected, but when I open the correct site that I need to open, it doesn't work. Is there anything a site could do to interfere somehow? Or is there an alternative way that I could try to open an external site in a new window and check when it is closed?

about 4 years ago · Juan Pablo Isaza
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!