weballey logo
left Frames - targeting backnext right
homesearchsite mape-mail
< targeting >
bad things
quick recap
      Inside frames, links behave much as they would in any browser window. Click on a link and the linked page will appear in the same frame. A very powerfull feature of frames however, is that you can click on a link, and let another window show the new page. The page with the link stays where just it is. A good use of this is creating a navigation bar with the links, and a main window to display the linked pages.

Show me! <FRAMESET COLS="150,*">
<FRAME SRC="navigation.html">
<FRAME NAME="main" SRC="mainpage.html">

    The COLS attribute is specified "150,*". This shows a 150 pixel wide frame to the left, and the remainder of the browser window for the other frame. It's best to always use an asterisk for the last frame, since there will be a blank area in your browser otherwise.

Names and targets
    More important here is the NAME attribute in the FRAME tag. To target a link, you will need a named window. Otherwise your browser won't know where to display what. The name will be used in the links in the navigation bar. Give your frames a proper name, that cannot be mistaken for anything else.

<A HREF="mainpage.html" TARGET="main">main page</A>

    This is a typical link to be used in frames. It is a normal hypertext reference, apart from the TARGET attribute. The TARGET attribute specifies the location where the linked page will be displayed. Be carefull about the spelling of the names and targets. If a target does not exist, your browser will open a new window. If no target is specified, the new page will be displayed in the wrong frame.
    To continue with the setup started on this page, all links in the navigation frame should contain this target. You may have links in the main frame, that change the menu bar. Then use a name and target for the menu bar too. You may have links to the home page, containing the frameset. Then make sure the whole thing doesn't load into the frame, giving you two menu bars. To prevent this there is a reserved target, named "_top".

Reserved targets
    There are some target names reserved for special functions. They can easily be recognized by the underscore in front of them. Do not use them to target to a specific window. Don't use these names for your frames either. You may get unexpected results if you do.

  • _blank shows the linked page in a new browser window
  • _self shows the linked page in the same frame the link is in
  • _parent shows the link in the parent page or frameset
  • _top shows the link in the full browser window
Base target
    Often you will only use one target for all links from your menu. In that case you can add a BASE tag to the HEAD section of your document. This target will then be used for all links in the web page. This will save you some typing, and may prevent possible typos.

<BASE TARGET="main">

goto top  
leftCopyright © Gerben Hoekstra - All rights reserved backnext right