child.htm.
- By Steven W. Disbrow
- August 14, 2000
JavaScripting
Window to window communication
Steven W. Disbrow
Listing 2. child.htm.
<HTML>
<HEAD>
<TITLE>Window to Window Communication - Child Window</TITLE>
<script language="javascript">
var myParent = self;
var linked = false;
// This function checks to see if we have a link
// established with out parent window.
function checkLink() {
if (myParent != self)
linked = true
else
setTimeout( "checkLink()", 2000)
}
// This function calls a function in the parent window
function passInfo( f) {
if (linked)
myParent.showInfo( f)
else
alert("Link with parent window not yet established.... Try again in a few seconds!")
}
</script>
</HEAD>
<BODY onLoad="checkLink()">
<form name="f">
First name:<input type="text" name="fName"><br>
Last name:<input type="text" name="lName"><br>
<input type="button" value="Send Info To Parent Window" onClick="passInfo( this.form)">
</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].