Web Marketing and Site Promotion provides expert advice on Internet marketing, search engine optimization, and website promotion strategies. Helping you meet marketing objectives within the limits of budgets and resources.
Dealing with frames, framesets and framed pages with search engine optimisation in mind has been a common problem for years.
The crux of the problem is that many search engine spiders do not follow the frames sources from the frameset page, and even those few that do, will create the problem of visitors arriving at a page that is not located within its frameset, and thus may be lacking such vital features as a navigation menu.
Let us use an example to see what this means. Lets imagine that the frameset document is the index page of your site. Within that frameset are 3 frames. The top frame extends all the way across the window and contains the company name, logo, and the most vital of the navigation links. Below that top frame, on the left, is a slim, vertical navigation menu. Finally the largest portion of the window is given to the main content frame.
Click here to see this example.
Now, when the search engine spiders arrive at the index page of the example site, many (perhaps most) will be unable to follow the frameset to find the actual content pages. If the site is unoptimised, they may find nothing but a minimal NOFRAMES text saying something like "Your browser doesn't support frames".
In the above example, wave goodbye to the spider, there is nothing more for it to do, and the site has no chance of even having its content spidered, never mind ranked highly.
Now let's see what happens when a more advanced spider finds and follows the frameset (or when the brilliant webmaster at least provides links to the main content pages in the NOFRAMES area for spiders to follow).
The spider finds its way to the content pages of the frameset. It indexes the pages just like any other, and doesn't instead apply the ranking to the Frameset page. This means that if the listing for that page turns up in a search, the visitor will find themselves on a page that is out of context.
In our example, think how useless the main content pages would be without access to the separate navigation menu frame. Okay now you grasp the problem with frames, let us move on to fixing them.
The foremost solution in use is to create a dynamic frameset page. A frameset that can build itself around any framed page that a visitor might land on out of context.
First we create a dynamic frameset page.
<html>
<head>
<title>Dynamic Frameset</title>
<script LANGUAGE="JavaScript">
<!-- Begin
if (top != self) {top.location.replace(location) }
var table_of_contents = "main.html";
var blank = " ";
var content = (location.search) ? location.search.substring(1,
location.search.length) : table_of_contents;
function fillFrame() {
parent.main.location.replace(content)
}
// Dynamic Frameset Script by Ammon Johns
// source: www.webmarketingplus.co.uk
// End -->
</script>
</head>
<script LANGUAGE="JavaScript">
<!-- Begin
document.write('<frameset cols="134, *" border="0"
frameborder="0" framespacing="0" onLoad="fillFrame();">');
document.write('<frame name="menu " src="menu1.html"
scrolling="auto" marginheight="10" marginwidth="5"
frameborder="0">');
document.write('<frame name="main" src="javascript:parent.blank"
scrolling="auto" marginheight="0" marginwidth="0"
frameborder="0">');
document.write('<\/frameset>');
// End -->
</script>
<noscript>
<frameset cols="134, *" border="0"
frameborder="0" framespacing="0">
<frame name="menu " src="menu.html"
scrolling="auto" marginheight="10" marginwidth="5"
frameborder="0">
<frame name="main" src="main.html"
scrolling="auto" marginheight="0" marginwidth="0"
frameborder="0">
</frameset><noframes></noframes>
</noscript>
</html>
The dynamic frameset does not need NOFRAMES content, since only browsers that support frames will ever be redirected here.
Next, we create a small JavaScript file that can redirect browsers which support frames over to the dynamic frameset page if, and only if, they view a page outside of its intended frames.
The following code is the content of the javascript file, which is a plain text file (.txt) but given a .js extension rather than .txt. i.e save this code in a text file, and rename it to dynamicframe.js.
if (top == self) {location.replace("dynamic_frame.html?"
+ self.location)}
That JavaScript file uses a conditional redirect. If whatever page that calls the JavaScript is not in a frame, it redirects to the dynamic frameset, passing its own location (URL) as a query string.
Finally, within each page that should only be viewed within its frameset, add the following code:
<script language="JavaScript" src="dynamicframe.js">
</script>
That takes care of all JavaScript enabled browsers, but that still leaves a small proportion of potential customers unserved.
For that reason, and for the benefits of getting our site properly indexed, you should create a separate frameset document for each and every main content page.
I'll state that again. While the JavaScript above is the 'standard' solution, I instead recommend that you create an individual FRAMESET page for each and every content page of your framed site.
Each frameset should be set to open just the specific content page it was created for as the default, and should contain NOFRAMES content specific to that one content page.
It is still advisable to use an external javascript file to redirect any browsers that are viewing a framed page out of the context of the frameset.
The easiest solution for making this easy is to have each specific frameset page named after the specific content frame that it belongs to:
e.g.
If my framed content page were products.html then my frameset
could be products-frame.html.
It is then relatively simple to create a single javascript of just a few lines in length that can correctly load up the frameset around any page viewed out of context.
if (top == self){
var myPage = self.location.href
var cropIt = myPage.lastIndexOf(".");
var frameUrl = myPage.substring(0, cropIt);
var frameUrl = frameUrl + "-frame.html";
top.location.replace(frameUrl);
}
// Script by Ammon Johns of www.webmarketingplus.co.uk
In doing this, you can set the hyperlinks in any pages to go straight to the framesets (with the attribute target="_top") rather than targeting the links to the content frame. This then works seamlessly for all users, browsers and spiders.
Browsers that support frames will still cache the common frames, such as navigation frames, and therefore still see a performance benefit typical of framed sites. Browsers that do not support frames automatically see the NOFRAMES content that is a plain, accessible version of the exact page they are seeking.
A perfect solution that suits everyone.
And that is what good coding is about.
Ammon Johns.
Web Marketing and Site Promotion Privacy Policy / Cookie Usage