Actually the question is how to check that the parent window exists and redirect it to another site.
I have met more than once on the Internet when you go to Google, for example, click on a link in Google, a site opens in a new window or tab, and the Google page is redirected to some kind of third-party site