Window openerProperty
Window Object
Definition and Usage
The opener property is a readable and writable property that returns a reference to the Window object that created the window.
When you open a window using window.open(), you can use this property to return detailed information from the source (parent) window of the target window.
Code Tip:window.opener.close() will close the source (parent) window.
Syntax
window.opener
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the opener property.
Examples
Examples
Write text to the opener window (parent window):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is my window</p>");
myWindow.focus();
myWindow.opener.document.write("<p>This is the source window!</p>");
}
</script>
</head>
<body>
<input type="button" value="Open my window" onclick="openWin()" />
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is my window</p>");
myWindow.focus();
myWindow.opener.document.write("<p>This is the source window!</p>");
}
</script>
</head>
<body>
<input type="button" value="Open my window" onclick="openWin()" />
</body>
</html>
Try it Yourself »
Window Object Other Extensions