Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

themadchemist

macrumors 68030
Original poster
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!
 
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.
 
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.
 
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.
 
Glad you got it working! Sorry about the bad advice. Clearly, I'm even more ignorant and forgetful of JS than I thought.
 
jsw said:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.