This application has three files: index.html
,
administer.html
, and
questions.js
. Since
index.html
is the frameset, let’s start
there. Example 2.1 leads the way.
Example 2-1. The index.html Source Code
1 <HTML> 2 <HEAD> 3 <TITLE>JavaScript On-line Test</TITLE> 4 <SCRIPT LANGUAGE="JavaScript1.1"> 5 <!-- 6 var dummy1 = '<HTML><BODY BGCOLOR=WHITE></BODY></HTML>'; 7 var dummy2 = '<HTML><BODY BGCOLOR=WHITE><FONT FACE=Arial>' + 8 'Strap in Bucko: This ain't no JavaScript vacation...</BODY></HTML>'; 9 //--> 10 </SCRIPT> 11 </HEAD> 12 <FRAMESET ROWS="90,*" FRAMEBORDER=0 BORDER=0> 13 <FRAMESET COLS="250,*"> 14 <FRAME SRC="administer.html" SCROLLING=NO> 15 <FRAME SRC="javascript: self.dummy1"> 16 </FRAMESET> 17 <FRAME NAME="questions" SRC="javascript: self.dummy2"> 18 </FRAMESET> 19 </HTML>
As you probably noticed, this isn’t your average run-of-the-web frameset y. First of all, it’s nested . That is, a frameset within a frameset. The outer frameset in line 12 defines two rows—the first 90 pixels high, and the second filling the rest of the available window height.
The 90-pixel frame also contains a frameset; this one declares two columns—the first 250 pixels wide and the second filling the remaining available window width. Figure 2.7 shows how the parent window is divided among frames. The SRC attribute of each frame is also listed.
administer.html
makes sense
as a SRC
for a FRAME
tag, but
what about the other two? The two dummy variables implicitly define
HTML pages. That means dummy1 and
dummy2 represent HTML pages with no filename.
Each exists only within the realm of the application. The dummy
variables are defined in lines 7 and 8. Notice that each contains a
small amount of HTML. Not much, but it will work.
index.html
uses the
javascript:
protocol to evaluate the expressions
contained in dummy1 and
dummy2, then returns each as the content of a
URL for the SRC attribute. Check out the sidebar JavaScript Technique: Cheating the SRC Attribute for more info.
The frameset is now in place. You have filled three frames using only
one HTML page (administer.html
). Talk about
economy.
3.144.25.74