Java Reference
In-Depth Information
function window_onload()
{
alert(“The name of the upper frame's window object is “ +
window.name);
alert(“The location of upperWindow's parent is “ +
window.parent.location.href);
}
</script>
</head>
<body onload=”window_onload()”>
<p>
Upper Frame
</p>
</body>
</html>
The preceding code block is the source page for the top frame with the name upperWindow and needs
to be saved as ch08_examp1_upper.htm . The fi nal page is very similar to it:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Chapter 8: Example 1 Lower Frame</title>
<script type=”text/javascript”>
function window_onload()
{
alert(“The name of the lower frame's window object is “ +
window.name);
alert(“The location of lowerWindow's parent is “ +
window.parent.location.href);
}
</script>
</head>
<body onload=”window_onload()”>
<p>
Lower Frame
</p>
</body>
</html>
This is the source page for the lower frame; save it as ch08_examp1_lower.htm.
These three pages fi t together so that ch08_examp1_upper.htm and ch08_examp1_lower.htm are
contained within the ch08_examp1.htm page.
When you load them into the browser, you have three window objects. One is the parent window
object and contains the fi le ch08_examp1.htm, and two are child window objects, containing the fi les
ch08_examp1_upper.htm and ch08_examp1_lower.htm. The two child window objects are contained
within the parent window, as shown in Figure 8-1.
Search WWH ::




Custom Search