|
Design Tip:
More About Frames
by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.
Many subscribers contacted us with questions and suggestions in response to our September article on frames. In this continuation, we'll pass along some of the suggestions we received and answer some of the most common questions.
NOFRAMES Tag Placement
Your NOFRAMES tag can go anywhere inside the FRAMESET tag in your document, but you should usually place it relatively early on the page. Remember that some search engine spiders may not read the entire text of your page (especially if it's a long one). If you place the NOFRAMES tag too far down in your code, some spiders may leave or time out before they're able to follow your alternate links.
Formatting Your NOFRAMES Tag
You can include other HTML tags inside your NOFRAMES tag. Use them to format the page color, layout, and images to resemble the rest of the pages in your site. For instance, your NOFRAMES section could look something like this:
<noframes>
<body bgcolor="#E8E7C8">
<DIV align="center">
<H1>Sally's Stamps</H1>
<H2>Your Source For Collectible Stamps!<H2>
<p><font face="Arial,'Times New Roman'"size="2">
Sally´s Stamps is the Internet´s largest source
for rare and collectible postage stamps. View our
stamps online before you purchase. We specialize in
stamps from Europe and South America.
</font></p>
<p><font face="Arial" SIZE="2">
Browse our site:<br>
<a href="home.htm">Home</a>
<a href="History.htm">History Of Stamps</a>
<a href="contact.htm">Contact Us</a>
<a href="products.htm">View Our Stamps</a>
</font>
</p>
</DIV>
</body>
</noframes>
|
When you include formatting, your NOFRAMES tag does double duty: it provides a gateway for search engine spiders while displaying an attractive document for visitors who don't have frames-compatible browsers.
Out Of Context Frames
Make absolutely sure there is a link somewhere on every page that returns visitors to the home page AND draws the entire frame:
<a href="index.htm" TARGET="_top">Home</a>
|
The page name "index.htm" in this case is the name of your top-level frameset that contains your home page. For instance, index.htm might consist of two individual frames: a navigation menu page named "menu.htm" and the actual home page named "home.htm." So, by linking to the main frameset, you ensure that the entire frame will be drawn and the pages displayed properly.
The TARGET="_top" loads the new document at the top-level window and replaces the page or frameset currently being displayed. This keeps any out of context pages indexed by search engines from becoming dead end pages that trap visitors with bad links.
You can also handle out of context pages by adding some simple JavaScript code to all your framed pages:
<script language="javascript" type="text/javascript">
<!-- Hide script from older browsers
if(top==self)
{self.location.href = "index.htm";}
//-->
</script>
|
This checks to see if the individual page has been loaded outside the frameset. If so, the script directs the browser to load the top-level frameset instead. This particular script always delivers visitors to the same frameset, no matter which page they were trying to view.
You can customize the script for individual pages if you have the time and inclination to create a separate top-level frameset for each page. More complex scripts can force the particular page into the frameset where it belongs, but they don't always display accurately across browsers: if you download some free code, test it as thoroughly as possible.
Keep Your Page Out Of A Frame
As link popularity becomes a more important ranking criterion for search engines, webmasters are eager to trade links with related sites. This is usually a win for everybody - unless an unscrupulous or inexperienced webmaster loads your page into his or her frame without attribution.
You can use a JavaScript script similar to the previous one to ensure that your page never gets loaded into someone else's frame:
<script language="javascript" type="text/javascript">
<!-- Hide script from older browsers
if(top!=self)
{top.location = self.location;}
//-->
</script>
|
This script checks to see if the current page location is the top-most in the browser hierarchy. If not, then the script forces the page to the top level and displays it as the current page in the browser.
Frames are controversial in the Internet community because they are often buggy and unpredictable. If you use frames, be sure to test your site across as many browsers and browser versions as possible.
NetMechanic's HTML Toolbox will scan your page and alert to problems that may cause your framesets to display incorrectly.
|