[Javascript] How do I located a window I opened?
Peter-Paul Koch
gassinaumasis at hotmail.com
Tue Aug 7 12:11:13 CDT 2001
>FACTS:
>
>the window object is the global object for client-side JavaScript and all
>global variables are properties of the window object
>
>and the window object that represents a top-level browser window exists as
>long as that window exists.
>
>and a reference to the window object remains valid regardless of how many
>web pages the window loads and unloads...
but a window object is only accessible from a window object that has some
kind of relation with it.
>soooo...
>
>QUESTION:
>
>How do I reference a window that I named
>
>using the window.name ="mywindow"
As far as I know you can only do that in pure JavaScript if the window is
1) either a child frame or a parent window of the window the script is in
2) the window the script is in has either been opened by or has opened the
other window
If there is no relation at all between the two windows (if the user has
started up both independently), there is no direct communication possible.
At least, that's what I think and I tried some strange things!
Note that the TARGET attribute of the A tag does allow this kind of
communication, a simple TARGET="mywindow".
What you can do is
<A HREF="javascript:someFunction()" TARGET="mywindow">
and the function someFunction() which resides in the other window will be
executed. So it is possible to call scripts in the other window. But since
JavaScript still doesn't allow you to refer to the other window the scripts
would have to be called by link tags like the above.
In short, this is a complex but fascinating subject.
ppk
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
More information about the Javascript
mailing list