Frames/iFrames and Search Engines

Frames Obsolete

Before You Proceed!

The frameset and frame tags are not supported in HTML5.

Therefore, we have replaced our frames pages with information on using iframes.

iframes and
Redirecting Source Pages

The documents that appear in our iframe windows are just plain ole HTML pages.

Our source pages displayed in the content iframe contain information, but no header and footer like the main 'frameset' page.

 

Our toc pages that were displayed in the nav iframe (original design) contained nothing but links. Also no site header.

The problem is not getting them indexed on a search engine, but what happens if they are indexed and someone accesses the page directly.

What if a toc page was indexed and a surfer accessed the page.

All they would see is a list of links.

The same question arises for every source page that will exist on our website.

If a content page was indexed and a surfer accessed it in the SERPS they would see an HTML page with no frame wrapper.

One solution would be to place a hyperlink on each page with the caption Restore Frames. The hyperlink would be used to send the surfer to the main 'iframeset' page.

A Better Method

A better solution can be achieved by placing a little block of javascript in each page of your site.

index.html or main frameset

Place this block of javascript in the head section of your main 'iframeset' page:
<script type="text/javascript">
var fname="content"; //Content Frame **NAME**

window.onload=function(){
var d=document.location.search;
if(d!='')
top.frames[fname].document.location
.href=d.substring(d.lastIndexOf('?')+1,d.length);
}
</script>

Be sure to change this line if your content frame is not named content:

var fname="content"; //Content Frame **NAME**

Toc Pages

We don't want people accessing these directly, but if they do we want them to go to the main page of the site.

Add this block of javascript to the head section of all toc pages:
<script type="text/javascript">
if(self.location==top.location)self.location="index.html";
</script>

Now if someone directly accesses a toc page it redirects to the main frameset and the default content page is presented.

Note: Your main 'frameset' page should be named index.html. If it isn't change the page name in the javascript code.

Content Pages

We want content pages to redirect to the main frameset also. But we want the page that is directly accessed to appear in the content window. To do that we make a simple change to the block of code we placed in our toc pages.

Place this block of code in the head section of your content pages:
<script type="text/javascript">
if(self.location==top.location)
self.location="index.html?page4.html";
</script>

In this example, the page would be redirected to the main 'frameset' page but page4.html would appear in the content window.

If the page was named carrots.html, the code would change to:
self.location="index.html?carrots.html";