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!