Recently, at work, i made a redirection to another site. The maintainers of the other site contacted me and told me that their window.close
are not working anymore.
Here is a simple explanation of the problem:
let's say site A has an <a href="http://siteB" target="_blank" rel="noreferrer">
tag to navigate to the home page of site B.
In the home page of site B, when you use window.close()
, the window is closed. Now,(still in the site B), when the user navigates to another page (let's say /about
page), a window.close
in this page will not work. Chrome shows this warning:
Scripts may close only the windows that were opened by it.
But in the <a>
tag, when i replaced rel="noreferrer"
by rel="opener"
, window.close works in any page of the site B.
For rel="noreferrer"
, window.close
only works in the first page of the redirection.
If i understand well the warning message, it's because the /about
page was not opened by the site A, that's why window.close
will not work in that page. But my question is, why by just changing rel="noreferrer"
to rel="opener"
, window.close
now works everywhere in site B?