[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Talking to another window
SilverThorn wrote:
>
> Has anyone found a way for one window to talk to another?
> I thought about having one window write a cookie while the other monitors
> the cookie list - but I haven't tried it yet.
>
> -------------------------------------------
> Andrew Wooldridge (andreww@c2.org) |
> http://www.best.com/~wooldri/ |
> http://www.c2.org/~andreww/javascript/ |
> -------------------------------------------
It depends on what you mean by talk, but I think the answer is yes. If
you have a window which creates other windows, then if you save the
window id's of the secondary windows then you can access elements of
those secondary windows. I know you can use the document.open() and
document.write() methods to write actual HTML (or data) to the second
window, and you should be able to put information into JavaScript
variables there too (like your own window id). I haven't tried the
latter idea yet though. Here's an example of how to create and store the
id of a second window, and then write a line to it:
function newWindow(windowName)
{
// Bug requires two window.open calls
w2 = window.open(windowName);
w2 = window.open(windowName);
w2.document.open("text/html");
w2.document.writeln("This is an example of how to write to another
window");
w2.document.close()
return w2;
}
--
____________________________________________________
Robert Thuleen
Sr. Software Engineer
Science Applications International Corp (SAIC)
San Diego, Ca
mailto:thuleen@mls.saic.com
http://www.saic.com
http://www.free.cts.com/crash/t/thuleen