|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update parent window from child
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? Last edited by reenadpatel; 01-02-2003 at 01:07 PM. |
|
#2
|
||||
|
||||
|
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 penPopup();">Open Popup</a><br><br></body> </html> Khalid |
|
#3
|
||||
|
||||
|
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>
__________________
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.” —Tim Berners-Lee, W3C Director and inventor of the World Wide Web |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|