Click to See Complete Forum and Search --> : Update parent window from child


reenadpatel
01-02-2003, 11:33 AM
In Javascript I need to update the parent window with the contents of a file. The child window displays a list of files. So when the user selects the file, I need to close the child window and open the file in the parent window. I have a function for opening the file in the parent window. I want to call this function from the child window.

Can someone help me with this?


Thanks for the reply but..

I am using arrays for displaying the data in parent form from file selected from child form. So the array declaration and the function to fill the array data is in the parent form. I need to call this function from child form to display the file in the parent form. I am not able to access this parent form function. What is the right syntax for accessing a parent form function from a child form?

khalidali63
01-02-2003, 11:50 AM
xThe code snippet below will do just that


<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("<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>
<a href="javascript:openPopup();">Open Popup</a><br><br>

</body>
</html>

Khalid

Charles
01-02-2003, 11:52 AM
First, make sure that you are opening the child window properly:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Test</title>
<p><a href="test1.html" onclick="window.open(this.href, '', 'height=300,width=200'); return false">Child</a></p>

And then in your child window:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Test1</title>
<p><a href="http://www.w3.org/" onclick="if (window.opener) {window.opener.location=this.href; return false}">W3C</a></p>