October 16, 2000 - More on Forcing Frames
October 16, 2000 More on Forcing Frames Tips: October 2000
Yehuda Shiran, Ph.D.
|
HEAD
section:
<SCRIPT LANGUAGE="JavaScript">
<!--
if (window == top) top.location.href = "001016f.html";
// -->
</SCRIPT>
The script first checks whether the current window
is equal to top
. If it is, the top FRAMESET
file is assigned to top's address, overwriting the current lower-level frame. This link demonstrates this trick. The link points to a lower-level frame, but when you click it, the top-level FRAMESET
is loaded instead. This frame, on the other hand, does not include the script above, and thus does not force the top-level FRAMESET
when clicked.
Here is the code for the top-level FRAMESET
, 001016f.html
:
<HTML>
<HEAD>
<TITLE>Top Level FrameSet</TITLE>
</HEAD>
<FRAMESET COLS="200, *">
<FRAME SRC="001016a.html" NAME="leftcolumn">
<FRAMESET ROWS="100, *">
<FRAME SRC="001016b.html" NAME="toprow">
<FRAME SRC="001016c.html" NAME="bottomrow">
</FRAMESET>
</FRAMESET>
</HTML>
Here is the frame with the script above, 001016a.html
:
<HTML>
<HEAD>
<TITLE>Left Tall Frame</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
if (window == top) top.location.href = "001016f.html";
// -->
</SCRIPT>
</HEAD>
<BODY>
This is the left tall frame
</BODY>
</HTML>
Here is the right top frame, 001016b.html
:
<HTML>
<HEAD>
<TITLE>Right Top Frame</TITLE>
</HEAD>
<BODY>
This is the right top frame
</BODY>
</HTML>
And finally, here is the the right bottom frame, 001016c.html
:
<HTML>
<HEAD>
<TITLE>Right Bottom Frame</TITLE>
</HEAD>
<BODY>
This is the right bottom frame
</BODY>
</HTML>
Learn more about frames in Column 36, Frames and JavaScript, Part I, and in Column37, Frames and JavaScript, Part II.