English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window opener property

JavaScript Window Object

openerProperty returns a reference to thewindow.open() Reference to the window that opens the window.

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

Syntax:

window.opener
// Open a new window
var win = window.open("", "popupWindow", "width=")300, height=200");
// Write some text in the new window
win.document.write("<p>This window's name is: " + win.name + "</p>
// Write some text in the window that creates a new window
win.opener.document.write("<h1>This is the source window!/h1>)
Test See‹/›

Browser Compatibility

All browsers fully support the opener property:

Properties
openerYesYesYesYesYes

Technical Details

Return Value:Reference to the window that created this window; if this window was not opened through a link to another window or created by another window without opening, it returns null

Related References

Window (Window) Reference:window.open() method

Window (Window) Reference:window.close() method

JavaScript Window Object