Javascript parent and child window functions
<p></p>

<p>function myFunction(){</p>

<pre><code>myWin = open("","","width=200,height=200");

with(myWin.document){
  open();
  write("&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Child Window&lt;/TITLE&gt;");
  write("&lt;SCRIPT&gt;function myTest(){");
  write("alert('This function is defined in the child window ");
  write("and is called from the parent window.'); this.focus();}");
  write("&lt;/SCRIPT&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H3&gt;Child Window&lt;/H3&gt;&lt;HR&gt;");
  write("&lt;FORM&gt;&lt;INPUT TYPE='button' VALUE='parent window function' ");

        write("onClick='opener.winFunction();'&gt;");                                            
   write("&lt;P&gt;&lt;INPUT TYPE='button' VALUE='close window' ");
   write("onClick='window.close();'&gt;");
   write("&lt;/FORM&gt;&lt;/BODY&gt;&lt;/HTML&gt;");
   close();
 }
}

function winFunction(){
    alert("This function is defined in the parent window\n" +
          "and is called from the child window.");
    myWin.focus();
}
</code></pre>

<p>//-->
</p>







<p>To explain further what my initial query was, the code above, should open the child window (myWin) with the second button, the 'Open child window' button without the need to open the window with the first button or do anything else. It should simply call the myWin.myTest()function The child window will open when the second button is pressed but needs to have the child window open first (first button push) before it'll work. This is not the intended purpose, the 'Open child window' button should work without anything else needing to be done. For some reason the parent window isn't communicating with the myWin window and myTest function. It's not homework, it's part of a certification course lab and is coded in the manner I have been shown to understand as correct. DTD isn't included as the focus is the JavaScript. I code correctly with regards to that and other W3C requirements.</p>
