| Get your FREE home page! |
| FRAMED! the tutorial |
| [ Home | The Tutorial | The Case Against Frames | Mail ] |
|
This is the 1997 tutorial, cleaned up and corrected over the years. Everything here works in Netscape Navigator 2 and later and Internet Explorer 3 and later. The code is shown in typewriter type; type it into Notepad or SimpleText exactly as it appears. Lessons: 1. The frameset page · 2. Splitting it again · 3. Names and targets · 4. NOFRAMES · 5. Borders · 6. Breaking out Lesson 1: The frameset page A framed site needs one extra page that holds all the others. Think of a window sash: the sash isn't the view, it just holds the panes of glass. The frameset page is the sash. It has a HEAD like any page, but no BODY. Where the BODY would be, it has a FRAMESET.
Save that as index.html. Now make two ordinary pages, menu.html and home.html, each with its own BODY, and upload all three. COLS splits the window left to right; ROWS splits it top to bottom. The sizes can be pixels (150), percentages (25%) or a star, which means "whatever is left over." So cols="150,*" is a menu 150 pixels wide and everything else for the main page. cols="*,2*" gives you one third and two thirds. My advice: make the menu a pixel size and the main page a star, so the menu doesn't get fat on a big monitor and skinny on a small one. Lesson 2: Splitting it again Want a banner across the top and a menu on the left? Put a FRAMESET inside a FRAMESET. The outside one splits the window into a top row and a bottom row, and the inside one splits the bottom row into two columns.
Count the files: the frameset page, the banner, the menu and the main page. That's four pages to show your visitor one screen. Hold that thought until you read the other half of this site. Lesson 3: Names and targets This is the lesson everybody skips and the one that causes ninety percent of my mail. When you click a link inside a frame, the new page loads in that same frame unless you say otherwise. So if your menu says
your recipes will open inside the skinny menu frame, 150 pixels wide, and your menu will be gone. That's why we gave each frame a NAME in Lesson 1. Use the name in a TARGET:
If every link on the menu page goes to the main frame, save yourself the typing and put one line in the HEAD of menu.html: <base target="main">. Now every link on that page aims at the main frame unless the link says otherwise. There are four special targets that start with an underscore:
Lesson 4: NOFRAMES Some browsers can't show frames at all: text browsers like Lynx, some of the little browsers on set-top boxes, and a surprising number of the robots that build search engine indexes. What they get is whatever you put between NOFRAMES tags, just before the last </frameset>:
Please don't write "Your browser doesn't support frames. Get a better browser." That's rude to the person, and it's the only sentence a lot of search engines will ever list for your whole site. Put real words and real links in there. Lesson 5: Borders, scrollbars and margins By default you get a thick gray bar between the frames that visitors can drag around. To get rid of it you need three attributes on the FRAMESET, because Netscape listens to BORDER, Internet Explorer listens to FRAMESPACING, and both of them know FRAMEBORDER. Put all three in and everybody's happy:
Lesson 6: Breaking out of somebody else's frames If other webmasters link to you without _top, your page shows up inside their frames, with their banner over your head. Put this in the HEAD of your own pages and they'll pop themselves out into the full window when that happens:
The <!-- and // --> hide the script from old browsers that don't do JavaScript, so they don't print it on the screen. One warning: don't put this in pages that are supposed to live inside your own frameset, or they'll break out of yours too, and you'll have written the best argument against frames on this whole site. That's all six. If something doesn't work, check your TARGETs first, then check that every FRAMESET has its closing tag, then write me. And then, before you upload, go read the case against. Humor me. |
|
Home | The Tutorial | The Case Against Frames Sam Troup · [email protected] Last updated: Saturday, September 18, 1999 |