Forum Moderators: open

Message Too Old, No Replies

How to get to a Child of a child's parent window

         

mikemcs

1:56 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



I have a parent window called A. A opens a child window called B. B then opens a new window on to its self, call it B2. I need to get to a function on A from B2.

B window:


<INPUT TYPE="button" NAME="myButton" VALUE="Next" onClick=" opener.AddIcnPopUp(\'icnwizpart=\' + partnumber.value + \'&icnwizqty=none\')">

B1 window


<INPUT TYPE="button" NAME="myButton" VALUE="Next" onClick=" (****WHAT CAN I PUT HERE****).AddIcnPopUp(\'icnwizpart=\' + partnumber.value + \'&icnwizqty=\' + qty.value)">

A window:


<INPUT TYPE="button" NAME="myButton" VALUE="Next" onClick=" AddIcnPopUp(\'icnwizpart=\' + partnumber.value + \'&icnwizqty=none\')">
<script>
function AddIcnPopUp(varstring)
{
URL = 'http://www.(MYSITE).com/poem/po/PurchQ3.php?' + varstring ;
window.open(URL,"AddIcnPopUp","'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=100'");
}
</script>

john_k

2:05 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe that the opener function returns a reference to a window object. Therefore use opener twice:

var winA=window.opener.opener;

mikemcs

2:15 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



thats it thanks

mikemcs

2:17 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



I may have spoke too soon. This did not work, but I think it is becasue I overwrite B with B2

DrDoc

2:43 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If B2 opens in itself, you should not need to use a window.open call... Instead, use location.href. Then you can use window.opener as normal.

Rambo Tribble

3:27 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might find something like this easier to maintain:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Playing with Windows 04.14.04</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
var win_num=new Array();
var win_cnt=0;
function winBld(){
var stack_xy=win_cnt*20+50
win_num[win_cnt]=window.open("","win"+win_cnt,"left="+stack_xy+"px,top="+stack_xy+"px,height=200px,width=200px");
win_num[win_cnt].document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'+
'"http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Untitled</title>'+
'<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"></head>'+
'<body><a href="javascript:opener.winBld();">Fire away</a></body></html>');
win_num[win_cnt].document.close();
win_cnt++;
}
function winKill(){
var l=win_num.length;
for(var i=l-1;i>=0;i--)win_num[i].close();
}
//-->
</script>
</head>
<body onunload="winKill();">
<div><a href="javascript:winBld();">Fire one</a></div>
</body>
</html>