[Javascript] Accessing forms in remote windows.

Larry Cotton laurence.cotton at ntlworld.com
Thu Dec 12 04:21:45 CST 2002


Hi

(Sorry about forgetting to put in a subject !!)

There is no form created by the javascript code in WinOpTst.htm.

WinOpTst.htm uses window.open() to open a window and load popPgTst.htm (if 
it hasn't already been opened) and naming it "PopPgTst". The javascript 
stores the returned reference to the window in a variable called popPgWin.

PopPgTst.htm contains a form called "form1" (standard html).

Once the window has been opened (with PopPgTst.htm) the javascript then 
tries to access the form object in the standard way, but through the window 
reference returned by window.open() :
popPgWin.document.forms.form1

As I understand it (but I may well be wrong) the window.open(<url>, <name>) 
function should open a new browser window, load the  page identified by 
<url>, name the new window <name> and return a reference to the new window 
(which can then, of course, be used in the same way as any window object).

This indeed seems to be the behavior in IE5, but in NN7 the form object 
does not seem to be created (though the document object exists and the page 
is displayed correctly in the new window).

Cheers
Larry


At 12:07 11/12/2002 -0600, you wrote:
>I am confused about this code.  I do not see any thing that creates a form
>on the Javascript created page.  It would look like:
>popPgWin.document.write('<form>') & popPgWin.document.wrte('</form>') to
>open and close a form created with JavaScript.
>
>----- Original Message -----
>From: "Larry Cotton" <laurence.cotton at ntlworld.com>
>To: <javascript at LaTech.edu>
>Sent: Wednesday, December 11, 2002 11:23 AM
>Subject: [Javascript] (no subject)
>
>
> > Hi
> >
> > I'm attempting to update some information in a form using an external
> > reference to a window opened using the open() method.
> >
> > My test scripts look something like (deb_prn simply writes to a debug
>window) :
> >
> > WinOpTst.htm - file containing the code to open the window
> > ----------------------
> > <script language="javascript" type="text/javascript"><!--
> > var popPgWin = window.open("popPgTst.htm", "PopPgTst");
> >
> > deb_prn("popPgWin.document.forms.length = " +
>popPgWin.document.forms.length);
> > deb_prn("popPgWin.document.forms[0].name = " +
> > popPgWin.document.forms[0].name);
> > deb_prn("popPgWin.document.forms.length = " +
>popPgWin.document.forms.length);
> > deb_prn("popPgWin.document.forms.TextBox1.value = " +
> > popPgWin.document.forms.form1.TextBox1.value);
> >
> > //--></script>
> >
> > popPgTst.htm
> > ----------------------
> > <body>
> > <form name="form1">
> > <input type="text" name="TextBox1" value="Hello" size="20"></input>
> > </form>
> > </body>
> >
> > When I open WinOpTst.htm in IE 5 the output I get is :
> > popPgWin.document.forms.length = 0
> > popPgWin.document.forms[0].name = form1
> > popPgWin.document.forms.length = 1
> > popPgWin.document.forms.TextBox1.value = Hello
> >
> >     ... which is almost what I expect, except for some reason the length
>of
> > forms[] returns 0 until the form itself has been accessed.
> >
> > When I open it in Netscape 7.0 the output is :
> > popPgWin.document.forms.length = 0
> >
> > and there is an error message saying ' popPgWin.document.forms[0] has no
> > properties'
> >
> > Does anyone know what is going on here and how I can access the form in
> > Netscape ?
> >
> > Cheers
> > Larry
> >
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list