In other words, if window
A opens window
const openerWindow = window.opener
Window-like object referring to the window that opened the current
window.open(), or by a link with
target attribute set). If this window was not opened by being linked to or created by
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. However, navigation of the opener window is possible, which means that the opened page can open an URL in the original tab or window. In some cases, this makes phishing attacks possible, where a trusted page that is opened in the original window is replaced by a phishing page by the newly opened page.
In the following cases, the browser does not populate
- The opener can be omitted by specifying
on a link, or passing
- From Firefox 79, windows opened because of links with a
_blankdon't get an
opener, unless explicitly requested with
- Having a
Cross-Origin-Opener-Policyheader with a value of
opener. Since the new window is loaded in a different browsing context, it won't have a reference to the opening window.
|HTML Living Standard
The definition of 'window.opener' in that specification.
BCD tables only load in the browser