Forum Moderators: open

Message Too Old, No Replies

How to get the parent to look at the child.

parent looking at the child.

         

tommytx

10:32 pm on Jul 17, 2006 (gmt 0)

10+ Year Member



I have the following code an I am trying to get the parent to look at a field in the child. I can get the child to look back ok using the window.opener, but the parent is not looking in the new_window to see what is there.
Can anyone see what i am doing wrong?

Thanks in advance...I must just have the reference I tiny bit wrong.

The following data is located in a file named "test001.htm"
***********************************************************

<script>
function doit1() {
var new_window = "scrollbars,resizable,width=200,height=200,left=400,top=25";
OpenWindow = window.open("test002.htm", "remote", new_window);
}
</script>

<script>
function doit2() {
alert(new_window.document.myForm.myField.value);
}
</script>

<body>

<P><A href="javascript:doit1()"><STRONG>Open Window</STRONG></A></P>

<P><A href="javascript:doit2()"><STRONG>Get Tommy</STRONG></A></P>

The following data is located in test002.htm
********************************************

<form name="myForm" action="">
<input name="myField" TYPE="TEXT" VALUE="Tommy"><br>
<input name="Submit" TYPE="Submit" VALUE="Submit"><br>
</form>

johnl

11:26 am on Jul 18, 2006 (gmt 0)

10+ Year Member



hi,
first, your variable name new_window is not good, as it contains properties of the new window and does not point to the new window.
second, the variable OpenWindow points to the new window, but is reachable from within doit2() only if it is not declared within another function, but globally.

So the following (untested) should work for you:


<script>
var Openwindow;

function doit1() {
var wprops = "scrollbars,resizable,width=200,height=200,left=400,top=25";
OpenWindow = window.open("test002.htm", "remote", wprops);
}
</script>

<script>
function doit2() {
alert(OpenWindow.name);
alert(OpenWindow.document.forms["myForm"].myField.value);
}
</script>

<body>

<P><A href="javascript:doit1()"><STRONG>Open Window</STRONG></A></P>

<P><A href="javascript:doit2()"><STRONG>Get Tommy</STRONG></A></P>