FRAMES and WINDOWS

TARGET, a new attribute of the <A> tag.

TARGET="window_name". Normally when you press a hyperlink, the contents of the new page replace the contents of the page that you are viewing. The TARGET attribute enables you to direct the page to a different window on the screen that is assigned with the "window_name". This name can start with any character except the underscore "_". If there is no window with that name, a new window is opened and given that name.


Creating a new WINDOW

Here is how it works. First you create an HTML file that you want to have loaded into the new window, say "newin.htm. Next you decide on a TARGET name, say "new_window". Finally you make the <A> ANCHOR tag like this:
<A HREF="newin.htm" TARGET="new_window">Open</A> a new window.
Here is how it will look on the screen:
Open a new window.

Now to put some new text in an exsisting window. This is almost the same as opening the window. The only difference is that you use a TARGET name that already exists. Here is an example:
<A HREF="newtext.htm" TARGET="new_window">LOAD</A> some new test into the new window.
LOAD some new test into the new window.


The <BASE> Tag

If you include the BASE tag in the <HEAD> ... </HEAD> block, every <A> tag that does not have a corresponding TARGET attribute will display it's document into the window specified by <BASE TARGET="window_name>.



FRAMES

To use frames, you need a Frame Definition Document that contains the layout of each frame and the names of the HTML documents that will fill them. Then of course you need the HTML files that will go into each of these frames.



The <FRAMESET> Tag

To create a "frame definition document", you use the <FRAMESET> tag. This tag replaces the <BODY> tag as shown here:

<HTML>
<HEAD>
<TITLE>Page Name</TITLE>
</HEAD>
<FRAMESET>
Your frame definitions goes here.
</FRAMESET>
</HTML>

If there is a FRAMESET tag, there can not be a BODY tag. In addition, no other formatting tags, hyperlinks, or document text should be included in a frame definition document. Of course there is an exception, and that is the <NOFRAME> tag. This is covered below somewhere.



The COLS Attribute

When you define a <FRAMESET> tag, you must include one of two attributes as part of the tag definition. The first of these attributes is the COLS attribute, which takes the following form:
<FRAMESET COLS="column width, column width,...">
The COLS attribute tells Netscape to split the screen into a number of vertical frames whose width is defined by the column width values separated by commas. Width (like Height) can be specified in three ways.

The following code would divide the screen into 3 columns, the first 100 pixels wide, the second is 50% of the screen width, and the third is what ever screen is left over.
<FRAMESET COLS="100,50%,*">



The ROWS Attribute

The ROWS attribute works the same as the COLS attribute except that it splits the screen into horizontal rows. To split the screen into two equal rows you could use either of the following:

<FRAMESET ROWS="50%,50%">
<FRAMESET ROWS="*,*">



The <FRAME> Tag

After you have set up your basic frames structure, you must associate an HTML file with each frame. This is where the <FRAME> Tag comes in.

<FRAME SRC="document URL">

For each frame defined in the <FRAMESET> tag you must include a corresponding <FRAME> tag as shown here:

<FRAMESET ROWS="*,*,*">
<FRAME SRC="document1.htm">
<FRAME SRC="document2.htm">
<FRAME SRC="document3.htm">
</FRAMESET>




Creating Complex Framesets

It is possible to nest <FRAMESET> tags inside of each other. Here is an example:

Open a framed window.

Here is the code that did that:

<A HREF="frame.htm" TARGET="framed_window">Open</A> a framed window.

the above opens the file below called frame.htm

<HTML>
<HEAD>
<TITLE>A Framed Window</TITLE>
</HEAD>
<FRAMESET COLS="20%,*">
  <FRAME SRC="dummy1.htm" SCROLLING="YES">
  <FRAMESET ROWS="20%,*">
    <FRAME SRC="dummy2.htm">
    <FRAME SRC="dummy3.htm">
  </FRAMESET>
</FRAMESET>
</HTML>



Named Frames and Hyperlinks

As mentioned earlier, the frame definition file does not describe the contents of each frame. It points to separate HTML files for the contents of each frame. If your page interacts with the user and needs to load up different files into one or more windows, it is necessary to give each frame a name. This is done in the frame definition file. After giving the SCR of the file that goes into the frame, you can add the NAME attribute to name the frame. Here is an example:

<FRAME SRC="Some_file.htm" NAME="frame_one">



Linking Documents to Frames

The command to place a document into a frame is the same as at the top of this page where it describes how to put a document into a named window:

<A HREF="newfile.htm" TARGET="frame_one">Load</A> frame one.



Other Frame Attributes

Here are sme other attributes that can be added to the FRAME tag after the SRC or NAME attribute like this:
<FRAME SRC="Some_File" Name="Frame_one" SCROLLING="NO">



<NOFRAME> Tag

If a browser that does not support frames, tries to load a frame definition file, it will display a blank page. To get around this you can include the <NOFRAME> tag in the FRAMESET file. This allows you to place Text, Images, and Links as an alternative for non-frame browsers to use. For example:

<HTML>
<HEAD>
<TITLE>Page Title</TITLE>
</HEAD>
<FRAMESET>
Your frame definition goes here
<NOFRAME>
Alternative Text, Image, and Links for browsers that can not handle FRAMES.
</NOFRAME>
</FRAMESET>
</HTML>



Magic Target Names

Assigning the following values to the TARGET attribute gives the following results: