[Javascript] Enumerating Other Window Objects

David Lovering dlovering at gazos.com
Fri Mar 21 15:07:17 CST 2003


I'll be jiggered.  My old HTML Master Reference lied to me!  (Isn't that the
same as "creative interpretation?").

Thanks for the note.

-- Dave Lovering

----- Original Message -----
From: "Chris Tifer" <christ at saeweb.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Friday, March 21, 2003 1:55 PM
Subject: Re: [Javascript] Enumerating Other Window Objects


> All 3 parameters are optional:
>
>
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
>
> Plus, when I put samples online to give solutions to problems, I normally
> do not do exact requests as I get paid for that, but more or less
generally
> give the user an idea on how to accomplish it.
>
> Chris Tifer
> http://www.emailajoke.com
>
>
> ----- Original Message -----
> From: "David Lovering" <dlovering at gazos.com>
> To: "[JavaScript List]" <javascript at LaTech.edu>
> Sent: Friday, March 21, 2003 3:48 PM
> Subject: Re: [Javascript] Enumerating Other Window Objects
>
>
> > Indeed.  I might add that the canonical usage of 'window.open' requires
3
> > parameters, not two.  The third is the most critical, and includes the
> > window geometry, placement, and chrome.  Some IE versions puke violently
> > unless you completely specify the three fields, even if they are null
and
> > consist of nothing more than (" ");
> >
> > -- Dave Lovering
> >
> > ----- Original Message -----
> > From: "Chris Tifer" <christ at saeweb.com>
> > To: "[JavaScript List]" <javascript at LaTech.edu>
> > Sent: Friday, March 21, 2003 1:46 PM
> > Subject: Re: [Javascript] Enumerating Other Window Objects
> >
> >
> > > It works the same way as if you were to loop through the collections
in
> > the
> > > same
> > > window, but instead you just need to know how to target it as I said
> > earlier
> > > through
> > > the handler you used when opening:
> > >
> > > // Called in the main window to open a new window
> > > // Just create a file named Test2.html and throw some links on it.
> > > var myWin = window.open("Test2.html", "TestWindow")
> > >
> > > // function is also in the main window and when you call the function
> > > // by doing: getLinks(myWin)  - since myWin is your window handle
> > > function getLinks(objWin){
> > >  linkCol = objWin.document.links
> > >  for(var x = 0; x < linkCol.length; x++){
> > >   alert(linkCol[x])
> > >  }
> > > }
> > >
> > > The problem would arise though if you left the page that has the
handler
> > set
> > > up as
> > > you won't be able to reference that window again unless you set up
> another
> > > handler.
> > >
> > > This works in both IE (4+) and NN 7. I would have tested on NN4 but
> thank
> > > god I don't have that installed on my machine.
> > >
> > > Chris Tifer
> > > http://www.emailajoke.com
> > >
> > > ----- Original Message -----
> > > From: <uplate at attbi.com>
> > > To: "[JavaScript List]" <javascript at LaTech.edu>
> > > Sent: Friday, March 21, 2003 3:18 PM
> > > Subject: Re: [Javascript] Enumerating Other Window Objects
> > >
> > >
> > > > I'm really trying to learn how to maneuver about a child windows
> > > collections.
> > > > I have no nefarious intentions in mind if that is what you are
asking.
> > > > > Interesting.  I'll have to look into that in more detail.
> > > > >
> > > > > It appears that you are more interested in capturing links/anchors
> > > rather
> > > > > than every object on the other page.  Am I right, or have I
> > > misinterpreted
> > > > > your request again?
> > > > >
> > > > > -- Dave Lovering
> > > > >
> > > > > ----- Original Message -----
> > > > > From: <uplate at attbi.com>
> > > > > To: <javascript at LaTech.edu>
> > > > > Sent: Friday, March 21, 2003 1:05 PM
> > > > > Subject: Re: [Javascript] Enumerating Other Window Objects
> > > > >
> > > > >
> > > > > > I guess my earlier email wasn't very clear. What I was
attempting
> to
> > > do
> > > > > was to
> > > > > > enumerate through objects on the child window opened with the
> > > window.open
> > > > > > method.
> > > > > > Here is my entire html document:
> > > > > >
> > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> > > > > > <html>
> > > > > > <head>
> > > > > > <title>Link Test</title>
> > > > > > <meta http-equiv="Content-Type" content="text/html;
> > > charset=iso-8859-1">
> > > > > > <script language="JavaScript" type="text/JavaScript">
> > > > > > <!--
> > > > > > var myWin
> > > > > >
> > > > > > function openWin()
> > > > > > {
> > > > > >     myWin = window.open("http://www.drudgereport.com","myWin")
> > > > > > }
> > > > > >
> > > > > > function printLinks()
> > > > > > {
> > > > > >     var str = "";
> > > > > >     for (i=0;i< myWin.document.links.length;i++)
> > > > > >     {
> > > > > >         str = str +  myWin.document.links[i] + "<BR>";
> > > > > >     }
> > > > > >     document.write(str);
> > > > > > }
> > > > > > //-->
> > > > > > </script>
> > > > > > </head>
> > > > > >
> > > > > > <body>
> > > > > > <input name="Button2" type="button" onClick="printLinks()"
> > > value="Print">
> > > > > > <input type="button" name="Button" value="Open"
> onClick="openWin()">
> > > > > > </body>
> > > > > > </html>
> > > > > >
> > > > > > Perhaps this isn't possible, I'm pretty new to javascript.
> > > > > > > I thought so too, until I did a descending tree analysis.
> > > Apparently,
> > > > > the
> > > > > > > window.opener sees as its first object a 'document', much like
a
> > > 'frame'
> > > > > > > does.  Again, to get at the soft and squishy insides you need
to
> > > punch
> > > > > > > through this crust by de-referencing to document.  [I've heard
> > tell
> > > that
> > > > > > > this is somewhat variable, depending on which version of IE
you
> > are
> > > > > running,
> > > > > > > and/or whether you are using a Netscape model browser].
> > > > > > >
> > > > > > > If you can wave your magic wand to make this go away, I'll be
> glad
> > > to
> > > > > cheer
> > > > > > > the process from the sidelines.
> > > > > > >
> > > > > > > -- Dave Lovering
> > > > > > >
> > > > > > > (BTW -- many of the things inside Microsoft manuals don't work
> as
> > > > > described.
> > > > > > > If you think you've found a case where this convention is
> broken,
> > > try
> > > > > using
> > > > > > > a getProps routine to map out the properties associated with a
> > given
> > > > > object
> > > > > > > layer.  I guarantee you many hours of fear, loathing, and
> > surprise).
> > > > > > >
> > > > > > > ----- Original Message -----
> > > > > > > From: "Peter Brunone" <peter at brunone.com>
> > > > > > > To: "[JavaScript List]" <javascript at LaTech.edu>
> > > > > > > Sent: Friday, March 21, 2003 11:34 AM
> > > > > > > Subject: Re: [Javascript] Enumerating Other Window
> > > > > > >
> > > > > > >
> > > > > > > > Point of parliamentary procedure:  shouldn't
> > > > > > > >
> > > > > > > > window.opener.parent.document.framename
> > > > > > > >
> > > > > > > > be
> > > > > > > >
> > > > > > > > window.opener.parent.framename
> > > > > > > >
> > > > > > > > ?  I don't think you can get to the frameset through the
> > document
> > > > > > > (although with IE 5.5 and above, you can treat iframes as CSS
> > > elements).
> > > > > > > >
> > > > > > > > Cheers,
> > > > > > > >
> > > > > > > > Peter
> > > > > > > >
> > > > > > > > ---------- Original
Message ----------------------------------
> > > > > > > > From: "David Lovering" <dlovering at gazos.com>
> > > > > > > > Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
> > > > > > > > Date: Fri, 21 Mar 2003 11:29:36 -0700
> > > > > > > >
> > > > > > > > >It isn't quite that simple.
> > > > > > > > >
> > > > > > > > >When a program spawns a remote, the parent can do pretty
much
> > as
> > > you
> > > > > > > said,
> > > > > > > > >and use
> > > > > > > > >
> > > > > > > > >    windowname.document.formname.varname.attribute  --
OR --
> > > > > > > > >
> > > windowname.document.framename.document.formname.varname.attribute
> > > > > > > > >// one or more frames
> > > > > > > > >
> > > > > > > > >to call up the bits in the child window(s).
> > > > > > > > >
> > > > > > > > >When the child program wants to access items in the parent
> > > window, it
> > > > > is
> > > > > > > a
> > > > > > > > >bit more complicated.
> > > > > > > > >
> > > > > > > > >    For a single form, no-frame parent:
> > > > > > > > >
> > > > > > > > >    window.opener.document.formname.varname.attribute
> > > > > > > > >
> > > > > > > > >    For multiframe, multiform parent(s):
> > > > > > > > >
> > > > > > > > >
>    window.opener.parent.document.formname.varname.attribute --
> > > OR --
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > >
> > >
> >
>
>window.opener.parent.document.framename.document.formname.varname.attribute
> > > > > > > > >
> > > > > > > > >  It gets REALLY tedious when you start embedding things
> inside
> > > > > <OBJECT>
> > > > > > > > >declarations, as it appears with
> > > > > > > > >MicroSloth's defective DOM structure you can only go from
the
> > > parent
> > > > > to
> > > > > > > the
> > > > > > > > >child, and not backwards.  I won't even attempt to give you
a
> > > path
> > > > > map
> > > > > > > for
> > > > > > > > >this -- it is too complicated to explain lucidly in a few
> > > sentences.
> > > > > > > > >
> > > > > > > > >  The reason the second 'document' declarations are needed
> > inside
> > > > > pages
> > > > > > > with
> > > > > > > > >frames is that the frame acts as a document boundary, and
to
> > > access
> > > > > the
> > > > > > > > >internals of one you must 'bust-through' the hard outer
layer
> > to
> > > get
> > > > > at
> > > > > > > the
> > > > > > > > >soft and chewy insides.
> > > > > > > > >
> > > > > > > > >  Hope this helps.
> > > > > > > > >
> > > > > > > > >  -- Dave Lovering
> > > > > > > > >
> > > > > > > > >----- Original Message -----
> > > > > > > > >From: "Chris Tifer" <christ at saeweb.com>
> > > > > > > > >To: "[JavaScript List]" <javascript at LaTech.edu>
> > > > > > > > >Sent: Friday, March 21, 2003 7:49 AM
> > > > > > > > >Subject: Re: [Javascript] Enumerating Other Window
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >> You just have to target which window you want to look
> through
> > > by
> > > > > > > > >> using the handler you used when opening the window.
> > > > > > > > >>
> > > > > > > > >> Chris Tifer
> > > > > > > > >> http://www.emailajoke.com
> > > > > > > > >>
> > > > > > > > >> ----- Original Message -----
> > > > > > > > >> From: <uplate at attbi.com>
> > > > > > > > >> To: <Javascript at LaTech.edu>
> > > > > > > > >> Sent: Friday, March 21, 2003 9:30 AM
> > > > > > > > >> Subject: [Javascript] Enumerating Other Window
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >> > Greetings;
> > > > > > > > >> >
> > > > > > > > >> > using the window.open() method is it possible to open
> > another
> > > URL
> > > > > and
> > > > > > > > >then
> > > > > > > > >> > enumerating through it's links or images arrays?
> > > > > > > > >> > Opening the window is no problem and even using a for
> loop
> > to
> > > > > > > retrieve
> > > > > > > > >the
> > > > > > > > >> links
> > > > > > > > >> > on the current document is no probllem, but I can't
seem
> to
> > > get
> > > > > the
> > > > > > > two
> > > > > > > > >> working
> > > > > > > > >> > together.
> > > > > > > > >> > Any ideas?
> > > > > > > > >> > Thanks.
> > > > > > > > _______________________________________________
> > > > > > > > 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
> > > > > > _______________________________________________
> > > > > > 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
> > > > _______________________________________________
> > > > 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
> >
> >
> > _______________________________________________
> > 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