Home| New Wiki | | Login | User registry | Home Tree PDF
Notify when a popup is closed
Owner:, Version: 2, Date:Fri 16, September 2005,

A web page can open a popup window to display or select information. To use this information from the main page some javascript is necessary:

Listing 1: 1.html, Opens a popup window

<html>
<head>
<title>Master</title>
<script>
function childClosed() {
  alert("childClosed!");
}
function openWindow() {    
	window.open('2.html','CloseMe','width=300,height=200');
}
</script>
</script>
</head>
<body>
<input type="button" name="action" value="Viva Chile" onClick="openWindow();">
</body>
</html>

Listing 2: 2.html, The popup page, contains a button that closes the window and notifies the master page.

<html>
<head>
<title>Child</title>
<script>
function notifyParent() {
  if (window.opener.childClosed!=null)
	  window.opener.childClosed();
}
function closeWindow() {    
	notifyParent();
	window.close();
}
</script>
</script>
</head>
<body>
<input type="button" name="Action" value="Close" onClick="closeWindow();"> 
</body>
</html>

Of course, the child page can send information or parameters back to the page....


Edit - History - Extract PDF - Extract Tree as PDF

Last Modified

Thu, Nov 19 Sat, Oct 3 Fri, Sep 25 Mon, Aug 3 Mon, Apr 27 Sat, Mar 28 Mon, Jan 19 Tue, Jan 6

Home| New Wiki