opener property of window object in javascript

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