<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>RE: [Javascript] Popup window stumper</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>If I understood well, you create a popup window from the main window and set</FONT>
<BR><FONT SIZE=2>the main window var newWind with the handler of the popup. And in the popup,</FONT>
<BR><FONT SIZE=2>you want to use this handler to set a popup declared var called theUser.</FONT>
<BR><FONT SIZE=2>So it's normal it doesn't work because vars only exists under their window.</FONT>
<BR><FONT SIZE=2>You can get your newWind var from the popup with a syntax such</FONT>
<BR><FONT SIZE=2>window.opener.newWind....</FONT>
<BR><FONT SIZE=2>or better</FONT>
<BR><FONT SIZE=2>document.....</FONT>
<BR><FONT SIZE=2>because theUser is declared in the popup so it can access directly the form.</FONT>
<BR><FONT SIZE=2>another solution is to give the popup a name as you create it </FONT>
<BR><FONT SIZE=2>(ie newWind = open(&quot;myurl&quot;,&quot;mynewwind&quot;...)</FONT>
<BR><FONT SIZE=2>and in the popup re-create it with the same name</FONT>
<BR><FONT SIZE=2>newWind = open(&quot;&quot;,&quot;mynewwind&quot;);</FONT>
<BR><FONT SIZE=2>and, as it already exists, you'll get a handle on the previously created window.</FONT>
</P>

<P><FONT SIZE=2>but if you want in the popup to access the from in the popup, </FONT>
<BR><FONT SIZE=2>use directly document.</FONT>
</P>

<P><FONT SIZE=2>for the alert messages while errors occurs, it often happens that</FONT>
<BR><FONT SIZE=2>the little icon is set ( in the left bottom corner of IE status bar )</FONT>
<BR><FONT SIZE=2>but the window doesn't appear.</FONT>
<BR><FONT SIZE=2>In a popup you may not have this status bar, so you don't see there was an error.</FONT>
</P>

<P><FONT SIZE=2>-----Message d'origine-----</FONT>
<BR><FONT SIZE=2>De : Terrence Donnelly [<A HREF="mailto:pag000@mail.connect.more.net">mailto:pag000@mail.connect.more.net</A>]</FONT>
<BR><FONT SIZE=2>Envoyé : samedi 15 décembre 2001 19:15</FONT>
<BR><FONT SIZE=2>À : javascript@LaTech.edu</FONT>
<BR><FONT SIZE=2>Objet : [Javascript] Popup window stumper</FONT>
</P>
<BR>

<P><FONT SIZE=2>Could somebody tell me why the following code doesn't work.&nbsp; This file</FONT>
<BR><FONT SIZE=2>is included as a .js file in the head of the main document. A simple</FONT>
<BR><FONT SIZE=2>click on a link calls function gologit.&nbsp; This function correctly</FONT>
<BR><FONT SIZE=2>makes a new window and displays the form and image in it, but clicking</FONT>
<BR><FONT SIZE=2>on the &quot;Log In&quot; button does nothing at all.&nbsp; I'm assuming I have</FONT>
<BR><FONT SIZE=2>some sort of reference problem and/or confusion between the</FONT>
<BR><FONT SIZE=2>parent and child windows, but I am stumped!</FONT>
</P>

<P><FONT SIZE=2>Thanks in advance.&nbsp; </FONT>
</P>

<P><FONT SIZE=2>*******************************************************************************</FONT>
</P>

<P><FONT SIZE=2>// golofile.js - opens a login window</FONT>
<BR><FONT SIZE=2>//&nbsp; adapted from</FONT>
<BR><FONT SIZE=2>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The Javascript Source!! <A HREF="http://javascript.internet.com" TARGET="_blank">http://javascript.internet.com</A></FONT>
<BR><FONT SIZE=2>var newWind</FONT>
<BR><FONT SIZE=2>function gologit() {</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>if (!newWind || newWind.closed) {</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newWind = window.open(&quot;&quot;, &quot;&quot;, &quot;HEIGHT=300, WIDTH=250&quot;)</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>if (!newWind.opener) {</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newWind.opener = window</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>}</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>var newContent = &quot;&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Grolier Online Log-In&lt;/TITLE&gt;&quot;</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;&lt;SCRIPT LANGUAGE='JavaScript'&gt;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;function TryItOut() {&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var theUser = newWind.document.logform.userbox.value;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;theUser = theUser.toLowerCase;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var thePassword = newWind.document.logform.passbox.value;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var theUserLength = theUser.length-1;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var theUserFront = theUser.charAt(0);&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var theUserBack = theUser.charAt(theUserLength);&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var theFile = theUserFront + thePassword + theUserBack+</FONT>
<BR><FONT SIZE=2>'.htm';&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;alert(theFile);&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;OpenIt(theFile);&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;window.close(newWind.opener)&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;}&quot;</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;function OpenIt(theFile) {&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;var root;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;if (opener.closed) {&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;root = window.open('','');&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;root.location.href = theFile;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;} else {&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;opener.location.href = theFile&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;}&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;}&quot;</FONT>
</P>
<BR>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;&lt;/SCRIPT&gt;&lt;/HEAD&gt;&quot;</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;&lt;BODY&gt;&lt;CENTER&gt;&lt;IMG SRC='grolog3.gif'&gt;&lt;P&gt;Please enter your</FONT>
<BR><FONT SIZE=2>Username and Password&lt;P&gt;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;&lt;FORM NAME='logform'&gt;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;Login Name:&amp;nbsp;&lt;INPUT TYPE='text' NAME='userbox' VALUE=''</FONT>
<BR><FONT SIZE=2>SIZE=10&gt;&lt;br&gt;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;Password:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;INPUT TYPE='password'</FONT>
<BR><FONT SIZE=2>NAME='passbox' VALUE='' SIZE=10&gt;&lt;P&gt;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;&lt;INPUT TYPE='button' NAME='button' VALUE='Log In'</FONT>
<BR><FONT SIZE=2>ONCLICK='newWind.document.TryItOut()'&gt;&lt;/FORM&gt;&quot;</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newContent += &quot;&lt;/CENTER&gt;&lt;/BODY&gt;&lt;/HTML&gt;&quot;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newWind.document.write(newContent)</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newWind.document.close()</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>} else {</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>newWind.focus()</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>}</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>****************************************************************************</FONT>
<BR><FONT SIZE=2>*******</FONT>
</P>
<BR>

<P><FONT SIZE=2>-- Terry Donnelly</FONT>
</P>

<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>Javascript mailing list</FONT>
<BR><FONT SIZE=2>Javascript@LaTech.edu</FONT>
<BR><FONT SIZE=2><A HREF="https://lists.LaTech.edu/mailman/listinfo/javascript" TARGET="_blank">https://lists.LaTech.edu/mailman/listinfo/javascript</A></FONT>
</P>

</BODY>
</HTML>