|
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....
|