Java Reference
In-Depth Information
as manufacturing web sites (for example, that of Ford or General Motors). Perhaps even more useful is
using small windows as dialog boxes, which you can use to obtain information from the user. Just as you
can script between frames, you can do similar things between certain windows. You fi nd out how later
in the chapter, but let's start by looking at scripting between frames.
Frames and the window Object
Frames are a means of splitting up the browser window into various panes, into which you can then
load different HTML documents. The frames are defi ned in a frameset-defi ning page by the <frameset/>
and <frame/> elements. The <frameset/> element contains <frame/> elements and specifi es how
the frames should look on the page. The <frame/> elements are then used to specify each frame and to
include the required documents in the page.
You saw in Chapter 6 that the window object represents the browser's frame on your page or document.
If you have a page with no frames, there will be just one window object. However, if you have more than
one frame, there will be one window object for each frame. Except for the very top-level window of a
frameset, each window object is contained inside another.
The easiest way to demonstrate this is through an example in which you create three frames, a top
frame with two frames inside it.
Try It Out Multiple Frames
For this multi-frame example, you'll need to create three HTML fi les. The fi rst is the frameset-
defi ning page.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Chapter 8: Example 1</title>
</head>
<frameset row=”50%, *” id=”topWindow”>
<frame name=”upperWindow” src=”ch08_examp1_upper.htm” />
<frame name=”lowerWindow” src=”ch08_examp1_lower.htm” />
</frameset>
</html>
Save this as ch08_examp1.htm . Note that the src attributes for the two <frame /> elements in this
page are ch08_examp1_upper.htm and ch08_examp1_lower.htm . You will create these next.
<!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 Upper Frame</title>
<script type=”text/javascript”>
Search WWH ::




Custom Search