PDA

View Full Version : javascript and multiple windows




themadchemist
Jul 25, 2004, 11:22 PM
Hi guys, another question. Is it possible for one to use javascript in one window to get information from another. For example:

Let's say you use window.open in a window called 'oldwindow' to create a new window called 'newwindow' that happens to have a form named 'john' and an input named 'doe' with some value.

Is it possible for 'oldwindow' to ask 'newwindow' what ...john.doe.value is?

And to make matters worse, 'newwindow' isn't allowed to do anything. In the scheme I'm imagining, I would not have any control of 'newwindow,' because my whole idea is to use 'oldwindow' as a portable console to get some information about the status of 'newwindow,' which is some other page.

Therefore, all of the scripting here needs to be in the 'oldwindow' page exclusively.

Thanks!



jsw
Jul 26, 2004, 07:55 AM
From my padawon-level knowledge of JS, no, it isn't possible. Some jedi-level guy might know of how to do it, but I think the windows can't communicate except indirectly via the server.

mnkeybsness
Jul 26, 2004, 12:21 PM
there is a way... i can't remember the specifics, but one window will need to be the parent of the other window... ie the parent needs to open the child. it does work because the browser is only running one java virtual machine, so the stack is the same for each window.

LeeTom
Jul 26, 2004, 12:24 PM
I'm sure it's possible, as I did it a long time ago. Did a 2-second Google search, and found this link.. it may be of help, especially on the 2nd or 3rd page somewhere

http://www.webreference.com/js/tutorial1/reference.html

EDIT: especially this page:
http://www.webreference.com/js/tutorial1/opener.html

Lee Tom

themadchemist
Jul 26, 2004, 01:47 PM
Thanks everyone, I was able to get it working! LeeTom, that page you pointed me to was especially helpful.

All it took was setting a variable to which window.open should return a value.

Now I should be able to finish up this little gadget I'm playing around with.

jsw
Jul 26, 2004, 02:18 PM
Glad you got it working! Sorry about the bad advice. Clearly, I'm even more ignorant and forgetful of JS than I thought.

themadchemist
Jul 26, 2004, 03:24 PM
Glad you got it working! Sorry about the bad advice. Clearly, I'm even more ignorant and forgetful of JS than I thought.

Oh, no problem. I thought it was definitely going to be a big challenge. It's funny how the darndest problems have the simplest, most obvious solutions.