opener property of window object in javascript

This property is used to return the  reference to the main window , which is used to create the window.

<html>
<head>
<script type="text/javascript">
function openmywindow()
{
mywin=window.open('','','width=100,height=100');
mywin.document.write("<p>My name is Mahak</p>");
mywin.focus();
mywin.opener.document.write("<p>This is the Main Window</p>");
}
</script>
</head>
<body>

<input type="button" value="Click Me!!!" onclick="openmywindow()" />

</body>
</html>



Output:


1.png
Ebook Download
View all
Learn
View all