简体   繁体   中英

Javascript - How do I detect when my popup window visits my site?

My site opens up a popup window to an external site, but at some point, the popup window will redirect to my site again. Because of security reasons, I know I can't look at the popup window URL until it redirects to back to my site. What I did is kept checking every second to see whether I could access the url address, and once I could, (meaning the popup window was back on my site) I stored the Url info and closed the popup. This seems like a pretty bad way of doing it...

Is there any way to detect the window returning to my site?

If you have control over the linkback page for the popup then you can set up a special page just for this purpose. All you'd need to do would be to create a page with some javascript that runs to notify you that you have come full circle.

One property that popup windows have is the window.opener property which refers to the parent window that initially created the pop-up.

This should be a good place to start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM