Home > Back-end >  Javascript wait for window to close before opening another
Javascript wait for window to close before opening another

Time:07-18

I need to open a series of popup windows, each window must be closed before the next one can be opened.

function openWindows() {
    var urls = getListOfUrls();
    
    for (let url of urls) {
        openWindow(url);
        // Wait for window to close before continuing.
    }
}

The only way I found to make sure that a window is closed is to use a setInterval which, as I understand it, causes the function behave asynchronously.

Any idea on how I can achieve this?

CodePudding user response:

Potential alternate suggestion

Without more information, it sounds like what you're trying to accomplish can be completely automated using pop-up blocked


You can try the code above in your browser JS console on this page, and (as long as https://stackoverflow.com is allowed to create popups) it should work.

  • Related