parent.htm.
- By Steven W. Disbrow
- August 14, 2000
JavaScripting
Window to window communication
Steven W. Disbrow
Listing 1. parent.htm.
<HTML>
<HEAD>
<TITLE>Window to Window Communication - Parent Window</TITLE>
<script language="javascript">
var childWindow = null
// Give the child window a link back to its parent
function makeLink() {
// Is the entire file loaded in the window?
if (childWindow.document.forms.length > 0)
childWindow.myParent = self;
else
// No? Wait one second and try again
setTimeout( "makeLink()", 1000)
}
// This function opens the child window
function openChild() {
childWindow = window.open( "child.htm", "child", "")
makeLink()
}
// Display the info from our child window
function showInfo( f) {
alert( "First Name - " + f.fName.value + "\nLast Name - " + f.lName.value)
}
</script>
</HEAD>
<BODY>
<form name="f1">
<input type="button" value="Open Child Window"
onClick="openChild()">
</form>
</BODY>
</HTML>
About the Author
Steven Disbrow is the owner of EGO Systems, a computer consulting firm in Chattanooga, TN. He can be contacted at [email protected].