Frames and Spiders Part 2

By Vince Barnes


Building the Right Environment to Support AI, Machine Learning and Deep Learning

Be Pretty and Be Spidered!

Part 2.

(return to Part 1)

We will now create three simple pages for our site. Nothing fancy or creative here -- you can put that on yours! Here's the code:

First our tile page, which is in a file called "title.html":

<base target="contents">
<body topmargin="15" leftmargin="15">
<p align="center"><b>
<font face="Arial" size="5">This is our Title</font></b></p>

Next is our contents page. This is in a file called "contents.html":

<base target="main">
<body topmargin="5" leftmargin="5">
<p><font face="Arial" size="2">
<a href="second.html">Second Body Page</a></font></p>
<p><font face="Arial" size="2">
<a target="_top" href="index.html">Home</a></font></p>

And finally, our first body page, which is in a file called "main.html":

<base target="_self">
<body topmargin="15" leftmargin="15">
<p>This is the Main page, which welcomes our visitors.</p>

Nothing too exciting about these pages, huh?! Do note, however, that in the contents page I have included an example of a hyperlink that overrides the default target frame and specifies "_top" which means it is to replace the entire contents of the browser window. This would, in our circumstances, have exactly the same effect as linking to "main.html" with no target specified, except that as is, the whole frames page will be refreshed.

That's it for the frames page and its contents. If you'd like to see it, click here.

I mentioned earlier about some misconceptions and tricks of the trade.

Firstly, some folks believe the frames have to have those ugly borders. As you can see here, that's not the case. You can achieve a clean, seamless look with "frameborder=0".

Secondly, and more importantly perhaps, is the question of search engine friendliness. The problem is this: you want the search engines to list you, so they need to be able to read your meta tags and your page content. The page that everybody is to go to is your frames page (our "index.html") but it has no content! We can put meta tags into it for those search engines that use them, but that won't help the spiders that look for content. When they find the content pages and list them, the visitor will be taken to a page that has no title and no navigation. Not too useful!

No problem! Here's what you do: put meta tags everywhere! That'll help your marketing efforts along. "But," you say, "what about those page that you don't want displayed without their frames page?" This little JavaScript is the answer:

<SCRIPT LANGUAGE="javascript">
if (self==parent)
document.write('<b>THIS IS A FRAME ELEMENT</B>')
document.write('You will be transported to frames in a second')
document.write('<META HTTP-EQUIV="refresh" CONTENT="1; URL=framepage.html">')

This little devil won't allow a page to be displayed without its parent frame! Replace "URL=framepage.html" with your own frames page name (in our case it would be "URL=index.html"). Insert this script into every page and each time a page is linked to, the visitor will be transported to your home page. This is exactly what you wanted. A little side benefit here: since you have so many pages that are being spidered, all of which will wind up on your home page, you are actually building a stronger presence in the search engines.

I know there are some who missed this before, or who didn't recognize its great value, but this gem has been in one of our tutorials (see here) for quite a long time!

Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.

    By submitting your information, you agree that htmlgoodies.com may send you HTMLGOODIES offers via email, phone and text message, as well as email offers about other products and services that HTMLGOODIES believes may be of interest to you. HTMLGOODIES will process your information in accordance with the Quinstreet Privacy Policy.

Thanks for your registration, follow us on our social networks to keep up-to-date