Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.opener is null after redirect

I am opening a paypal window from the parent with window.open(). After payment and redirecting back to my page (in the popup window), I would like to close the popup and update the parent window URL.

I found out this works over window.opener.location.

However the console shows

window.opener.location is null

after redirection because as the child window changes, the popup looses the information about the opener.

Well great. Now is there any way to get around this? Maybe adding a sort of "listener" to the parent who listens to the URL of the child?

like image 866
Mike Avatar asked Aug 19 '11 10:08

Mike


People also ask

Why is window opener null?

If this window was not opened by being linked to or created by another, returns null . If the opener is not on the same origin as the current page, functionality of the opener object is limited. For example, variables and functions on the window object are not accessible.

What is window opener?

The Window opener property in HTML DOM is used to return the reference of newly created windows. This property is used to return the details of the source (parent) window. A window is opened using the window. open() method and closed using the window. opener.

What is window opener location href?

location. href is not a method, it's a property that will tell you the current URL location of the browser. Changing the value of the property will redirect the page. window. open() is a method that you can pass a URL to that you want to open in a new window.


1 Answers

window.opener is removed whenever you navigate to a different host (for security reasons), there is no way around it. The only option should be doing the payment in a frame if it is possible. The top document needs to stay on the same host.

like image 106
Wladimir Palant Avatar answered Sep 22 '22 07:09

Wladimir Palant