Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9162227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:09:37+00:00 2026-06-17T14:09:37+00:00

The situation is like this. With JavaScript I open a window with a URL

  • 0

The situation is like this. With JavaScript I open a window with a URL on my domain showing a loading indicator.

After about a second, the URL of the window is changed to a PayPal window (so other domain). I want to be able to capture the event when the user closes the paypal window, so I can redirect the user to the correct page saying the payment failed.

I encountered window.onbeforeunload but that one is fired when the url changes to PayPal, but not when the window is closed after that. How do I overcome this issue?

So, this doesn’t seem to be working, and I can’t find any other answers around here:

    ppwin = window.open('paypal/loading.php', 'paypal_popup', 'width=900,height=500');
    ppwin.onbeforeunload = function(){
        //triggered when URL changes
        if (ppwin.closed) // false because window is still open.
            // Order failed
    }

Even though I accepted the answer, I am still not statisfied with it. It works, but thats it. If someone provides a better answer I would be much more happy!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:09:39+00:00Added an answer on June 17, 2026 at 2:09 pm

    I came accross the same problem and in the end what I did is to make the parent window periodically check if the popup window was closed. Any alternative solution drove me nuts.

    The code could be like this:

    // Create popup window
    var popup = window.open('http://www.google.com');
    
    // Set interval to check if it has been closed
    var windowCheckInterval = setInterval(function() { windowCheck(); }, 300);
    
    // Check function
    function windowCheck() {
        if (!popup || popup.closed) {
            clearInterval(windowCheckInterval);
    
            // Do something
        }
    }
    

    Despite it is quite a rude solution, user experience is quite good and programming is really simple.

    You must remember to clear the interval when process finishes in a different way (not just when the window is closed), it there is any.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the situation. I have some javascript that looks like this: function onSubmit()
I faced this strange situation where foreach like construct of javascript does not work
I have a really weird situation, I am calling my javascript function like this...
I have a situation like this. <php> <redirect the page > <exit> <javascript> <redirect
I have a situation like this. I have scrollpane whose viewportView is a JPanel
i have situation like this: class IData { virtual void get() = 0; virtual
I've got a situation like this: Table: FunTable ItemKey ItemName ItemPriceEffectiveDate ItemPrice 11 ItemA
I have situation like this: user submits form with action='/pay' in '/pay' I have
So I have a situation like this: A needs to call B service and
I have a situation like this: +------------------------------------------------------------------------------+ | | | +---------------------------------------------------+ | | |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.