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

142
Views
Cant close a popup B from a page A within the webView browser

I tried to find a solution here but couldn't.

The problem is the following:

  • I have a page A that opens a popup B that has some authentication.
  • After the authentication, page A(the window.opener page) closes the popup page B when it receives all done from the backend.

It works fine except when its opened from the webView "browser" from within the facebook app or chat on a phone.

So far I can see that the webView limitation is that you can only have one active tab. So when page A is not active its javascript code is not executed and the popup wont be closed.

You can test this with this fiddle from the webView browser.

let w = null;

window.addEventListener("DOMContentLoaded", (event) => {
  document.querySelector("button").addEventListener("click", () => {
    w = window.open("https://www.google.com", "customPopup", popupFeatures);
    window.setTimeout(() => {
        if (w) { w.close() }
        alert('parent js is working');
    }, 3000);
  });
  
});

const popupFeatures =
  "menubar=no,location=no,resizable=no,scrollbars=yes,status=no,width=700,height=700";
<button>.......CLICK here....</button>

Some limitations I cant circumvent:

  • Page B has to be a popup because safari blocks third party cookies, so no Iframe on page A.
  • The popup page / code doesn't have a redirect option, and I have no control over it.
  • The popup page also doesn't use postMessage or other method of communicating with other pages, I get the all done only from our backend that's requesting it from theirs.
  • I cant setup the popup B with my code because soon after opening, it redirects to another third party page.

Is there a way to keep the javascript code on page A to keep executing or being able to close the popup?

The main problem is after the popup opens and the user finishes with the authentication the flow is stuck there because I cant close it from page A since its javascript thread is not active.

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!