Monday, September 18, 2006

How to Not Frame the Issue

Remember when it was cool to have a frameset on your site? Me neither. Granted, I've been guilty of placing the things on my old free-hosted site back in the day, but I since learned the error of my ways. And now you can, too!

Why You Might Want To Use Framesets


Many developers want a consistent layout that's also easy to manage. When learning HTML and getting into greater numbers of files on your site, you reach a point where creating a new primary link from your navigation bar becomes a huge chore, because you have to edit each file on the site and plug the link into the proper place. Using Framesets lets you create one navigation file, and divide the rest of the site into content frame pages. That way, you only have to edit the one navigation file when a new link comes along.

There's also the keep-em-0n-site effect. If your site has outbound links to other sites, you'd normally want to use the target="_top" attribute on your link tag so that when a visitor clicks the link, their browser opens the linked page at the main browsing level, rather than opening it inside your content frame. But, what if you want to allow users to keep seeing your navigation frame even when they've clicked a link to another site? That way they can always click back into pages on your site, because it's in sight and in mind. And maybe you have some kind of advertising banner that you want to optimize by keeping it in view as much as possible.

Stop the Insanity! (Please)

Now, here's why those reasons to use framesets don't hold up, plus a few extra for good measure.

First, the issue of what to do when your site is so big (how big is it?) that you need to spend all day pasting links to new pages. Whatever into-to-HTML page or book you've been reading might not have mentioned it, or maybe your skills haven't gotten to that point, but there have been a few add-ons to HTML that will be a big help to you.

SSI allows you to grab the contents of one HTML file and embed it inside another file. This gives you the same effect of the navigation frameset, where you only have one file containing navigation links. The only differences are that each file on your site will explicitly include the navigation file, and there won't be a frameset. To do things the SSI way, you'll probably want to rename your file extensions from .htm(l) to .shtm(l), the S standing for SSI. That tells the web server, "Hey, this file is somewhat dynamic, and will require actual processing rather than just fetch/retrieve." Then, where you want to include another file, you use this comment code: or:
Most scripting languages also have some mechanism to do this, for instance in php, include("file.php");

You can also use a feature in Dreamweaver called Templates, where you create a template file, which has static and editable regions (parts of the file). Then you create your site files based on the template. Any time you edit the static parts of the template, Dreamweaver automatically rounds up all of the files based on that template and updates them to reflect the change. You can use this if your site doesn't support SSI or scripting.

Now for the other issue, regarding keeping users on your site: just don't! For one thing, it's annoying to your visitors. You may think you're doing them a kindness by allowing them to access other parts of your site even though they found a link to another site and followed it, and they can still instantly get back into your site. Well, think of it this way: if there was other content on your site that they were interested in, they would have bookmarked it. Or Digged it, or del.icio.used it, or just opened the link in a new tab/window, or viewed the other site and then hit the Back button or History to get back to your site. By leaving your frameset sitting there, you're cluttering their screen real estate, and forcing them to look at something they neither want nor expect to see. Not to mention, you could be violating the terms of use of the site to which you are linking: some of them have rules about not bringing their content into a frameset, and your site might end up on their list of banned referers. Your users probably don't want to click a link from your site, only to get a message that you are a naughty boy/girl.

Here's the best reason to drop the framesets: search engine optimization and accessibility. Think about it: in order to get at the actual content of your site, a user agent (user using a browser, or a search engine spider that is automatically following links and recording what it finds) has to make more connections to your site if you use a frameset. First, it requests the frameset file. (GET /index.html) When it reads that file, it finds your frameset tag, and the nested frame tags with their src attributes pointing to your navigation file and home page content file. So now, it has to make requests for both of those files. (GET /nav.html) (GET /home.html) This extra time spent getting the files reflects poorly on the value of your content, and thus, your search engine ranking will take a hit. Also, if a visitor is using a non-visual browser, then they're going to get a prompt asking them which frame they want to get information from. If they don't know which is navigation and which is content, they might make the wrong choice. And if your content pages don't link to the rest of the site, then they have to switch frames into the navigation frame in order to browse through your site. You want things to be simple for your visitors, to ensure that they refer you to others and keep coming back to your site. You don't want to turn them off by making things more difficult than they need to be.

If you've never worked with accessibility in mind, try downloading the Lynx browser, which is a text-only interface and does a pretty good job visualizing your accessible content. It's also a piece of history, and knowing how to use it will improve your geek-cred.

0 Comments:

Post a Comment

<< Home