Click to See Complete Forum and Search --> : accessing parent window variables from child
reenadpatel
01-09-2003, 10:06 AM
Hi,
I am new to Javascript. I have a parent window in which i have declared some variables and functions. Using window.open i open the child window and depending on the selection made by user i have to assign values to parent window variables...
Can anybody help me with this..how do i access parent window variables in child form..
Thanks,
Reena
khalidali63
01-09-2003, 11:26 AM
Code snippet below shows the syntax to communicate between parent window and child window.
WHn you open a child window it shows you an alert box with the text value from the parent window.
and onlck on a link on the child page will force to open a the link in the parent window.
Khalid
<html>
<head>
<title>Interaction with Pop Up Window - child/parent</title>
<script>
function openPopup(){
var popupWin = window.open("Blank.html","popupWin","width=300,height,300,scollbar=no,addressbar=no");
popupWin.document.open();
popupWin.document.write("<script>alert(top.opener.document.frm.txt.value);<\/script><a href=\"javascript:top.opener.document.location.href='http://www.cnn.com';self.close();\"\">Open CNN in parent Frame</a>");
popupWin.document.close();
}
</script>
</head>
<body>
<form name="frm">
<input type="Text" name="txt"></input>
</form>
<a href="javascript:openPopup();">Open Popup</a><br><br>
</body>
</html>
One Way to get some variables is the following syntax:
window.opener.yourForm.YourField.value;