To Frame or not

PC Pro logo Posted: 1st April 2001 | Filed under: Press Articles, Technical
Author: Paul Ockenden
First Appeared in PC Pro 2001

'Should I use frames on my site?' A common question, and one where the answers usually range from 'You should never use frames,' through to, 'I quite like frames, actually'. There's no doubt that frames, when used properly, can be an effective navigation aid for certain types of sites. On the other hand, when frames are used for solely cosmetic purposes, they can be quite annoying.

The usual reason cited for avoiding frames is that search engines won't be able to spider your site properly, and if they try they'll drop people straight into content frames without any site navigation. That's certainly true for static HTML sites, but most on-line e-businesses will nowadays be built using server-side technologies that can also be used to sort out some of these search engine problems.

What your site needs to do is to examine the User Agent of all accesses to your front page, and if it appears to be a search engine spider then don't serve up a frameset at all - instead do a trawl through your content database and generate a cascading series of pages about three levels deep with links to all of the content pages on your site. We've found such a cascaded list to be better than one long list, especially where there are many pages involved. Don't go any deeper than three levels though, or some search engines won't get to the final pages. You'll find lists of spiders published on various Web sites, and if you're a customer of ABC Electronic, it can provide you with a very comprehensive list.

Okay, so that gets the pages indexed, but how do you stop search engines from directing visitors straight into your unframed content? Well, whenever you serve up a content page, check the referrer field in the HTTP request - if it exists, and it isn't from this site, then intercept the page request and throw your frameset around it. Having said all that, please only use frames where they really add something, and please don't forget that anyone accessing the Web from something other than a desktop computer may be using a browser without frame support.