The Window interface's opener property returns a reference to the window that opened the window using open().

In other words, if window A opens window B, B.opener returns A.


openerWindow = window.opener;


A Window referring to the window that called open() to open the current window, or null if this window was not opened by being linked to or created by another.

In some browsers, a rel="noopener" attribute on the originating <a> element will prevent the window.opener reference from being set, in which case this property will return null.


if (window.opener != indexWin) {

Usage notes

When a window is opened from another window (using or a link with its target attribute set), it maintains a reference to that first window as window.opener. If the current window has no opener, this method returns null.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support YesEdge ? Firefox Full support YesIE ? Opera ? Safari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android ?


Full support  
Full support
Compatibility unknown  
Compatibility unknown