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.
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function openmywindow() {
  5. mywin = window.open('', '', 'width=100,height=100');
  6. mywin.document.write("<p>My name is Mahak</p>");
  7. mywin.focus();
  8. mywin.opener.document.write("<p>This is the Main Window</p>");
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <input type="button" value="Click Me!!!" onclick="openmywindow()" />
  14. </body>
  15. </html>
Output:
1.png