Frames allow you to divide the page into several rectangular areas and to display a separate document in each rectangle. Each of those rectangles is called a "frame".
Targeting Frames
Each frame is given a name using
<FRAME NAME="...">. These names uniquely identify each frame. Using these names, links in other frames can tell the browser which frames the link targets.
To target one of these frames, the link should have a
TARGET attribute set to the name of the frame where the linked page should appear. So, for example, this code creates a link to tfetacos.html and targets that link to the MAIN frame:
Eventually, in a framed site, you want to "break out"... link to a page and have that page take over the entire window. To create this sort of link, we add target="_blank" to the <A ...> tag:
<A HREF="wwtarget.html" target="_blank">
"_top" is a reserved name which is automatically given to the entire window
No Frames
Browsers that know frames will ignore everything between <NOFRAMES> and </NOFRAMES>. Browsers that don't understand frames will also not understand (and therefore ignore) <NOFRAMES> and display the content
To create a borderless frameset, use a
<FRAMESET ...> tag with
FRAMEBORDER,
FRAMESPACING, and
BORDER attributes like this:
- <FRAMESET ROWS="20%,*" FRAMEBORDER=NO FRAMESPACING=0 BORDER=0>
Restrict our page from iframe
If you don't want your page to be framed, put this little Javascript in the page:
- <SCRIPT TYPE="text/javascript">
- <!--
- if (top != self)
- top.location=self.document.location;
-
- </SCRIPT>
This script checks to see if the current page is the "top" page. If it is not, it tells the web browser to load the current web page as the top, thus wiping out any frames.
Always our page to be framed
Sometimes a particular web page only makes sense if it appears in a frame.
- <SCRIPT TYPE="text/javascript">
- <!--
- function checkframed(url)
- {
- if (top == self)
- document.write(
- '<DIV STYLE="padding:8pt;' +
- 'border-style:solid;border-width:8pt;' +
- 'border-color:66CC33;">' +
- '<STRONG>' +
- 'This page is intended as part of a ' +
- '<A HREF="' + url + '">framed document</A>.' +
- '</STRONG></DIV>');
- }
- checkframed("dgftop.html");
-
- </SCRIPT>
- FRAMEBORDER = YES | 1 | NO | 0
- FRAMESPACING = integer
- BORDER = integer
- COLS = integer
- ROWS = integer
- BORDERCOLOR = color expression
- SRC = "URL"
- NAME = "text string"
- SCROLLING = YES | NO | AUTO
- NORESIZE says that the user cannot make the frame bigger or smaller by sliding the borders
- FRAMEBORDER = YES | 1 | NO | 0