Naming and targeting frames

By default, when you click on a link in a frame, the results of that link will load in the same frame as the one you clicked in. Often, however, when you click on a link, you want to load the contents of that link in a different frame than the one you clicked in. To do this, you'll need to use the new TARGET attribute of the A tag, and a new ATTRIBUTE of the FRAME tag: NAME.

Give each frame in your frameset a frame name. This is done by adding the NAME attribute to the FRAME tag. You can name your frames anything you like, though it's best to keep it one simple word.

<FRAME SRC="mypage.html" NAME="mainframe">

Once you've assigned each frame a name, then you just need to add the TARGET attribute to each link's A tag. The TARGET attribute's value will be the name of the frame that you want the link to load into. So, if you have a menu frame on the left side of your page that contains a list of links, and you want those links to load in the right frame (named "mainframe"), then each link in the left frame will need to have the attribute TARGET added to it's A tag, like this:

<A HREF="newpage.html" TARGET="mainframe">Click this!</A>

(Remember, these A tags aren't in the FRAMESET. They are on the separate HTML page that you're loading into one of the frames.)

If all tags in the page point to the same target, you can place the tag <BASE TARGET="targetname"> in the HEAD section of the page. Then all links clicked on that page will automatically target the same place unless defined otherwise.

There are some special TARGET values that you may need occasionally to get the target you want:

TARGET="_self"
Links with this target will load in the same frame the link was originally located in. This is the default setting, so you usually don't need to specify it. Here's an example of this target behavior: Click this link to see TARGET="_self"


TARGET="_blank"
Links with this target will open a new browser window to display the linked document. This can be a problem, because the site visitor might end up with a ton of unwanted open windows. Use with discretion. Here's an example of this target behavior: Click this link to see TARGET="_blank"


TARGET="_top"
Links with this target will "break out" of the current frameset and display alone in the browser window. This is the most handy target, and is frequently used. Here's an example of this target behavior: Click this link to see TARGET="_top"

<<-------- p r e v // a i w e b // n e x t -------->>