title: how to add javascript code to newly create window head from javascript file
body: <p>I am doing a project where I want to open new window using <code>window.open()</code> from my js file and add javascript code to newly created window. Anyone know how to do it. I tried the following code to alert in new window. But not working</p>
  
  <pre><code>var mywindow = window.open('', '', 'scrollbars=1,height=600,width=600');
  mywindow.document.write("&lt;html&gt;&lt;head&gt;&lt;title&gt;Patient Data&lt;/title&gt;");
  mywindow.document.write("&lt;/head&gt;&lt;body&gt;");
  mywindow.document.write("Test");
  mywindow.document.write("&lt;/body&gt;");
  mywindow.document.write("&lt;script type='text/javascript'&gt; alert('HIiii'); &lt;/script&gt;");
  mywindow.document.write("&lt;/html&gt;");
  </code></pre>
  
  <p>Thanks in advance.</p>