Easy Tutorial
❮ Prop Frame Scrolling Prop Win Pagexoffset ❯

Window opener Property


Definition and Usage

The opener property is a read-write property that returns a reference to the Window object that created the window.

When a window is opened using window.open(), you can use this property to return details from the source (parent) window.

Code Tip: window.opener.close() will close the source (parent) window.

Syntax


Browser Support

All major browsers support the opener property.


Example

Writing text to the opener window (parent window):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</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>

❮ Prop Frame Scrolling Prop Win Pagexoffset ❯