Frames and Redirection
Frames can add a little extra character to any website. People seem to be fascinated by scrolling windows. In the past frames could present problems with search engines. Today with a little extra work even a frames site can ride the top of the search engine databases.
One of the most helpful tools in setting up for indexing is redirection. We show 2 types of redirection on this mini site. One method uses javascript and the other uses a meta statement in the head section of an HTML document.
If you want more information on these two methods of redirecting web pages you should go to the lessons in our HTML 4.0 Online tutorial. Check out the lessons on Frames and Search Engines and Meta Tags.
You can actually see the first method in action as you read the lessons. Watch as the pictures change in the bottom frame window on the left. Some sites use this method to rotate advertisements on their main frameset page. Proceed to Using Meta Tags to see how it is done.
Redirecting with Javascript
We don't recommend Javascript for beginners, but with a simple block of code we can solve some problems that come up when using frames.
When building a site with frames you have two different kinds of pages.
You have frameset pages and you have source pages.
Source pages are those that are assigned to a frame window with the src="" attribute, and display in the assigned window. (See Frameset Code)
Source pages are just plain Ole HTML pages.
What if a source page gets indexed on Google, comes up in a search result and someone clicks on it?
Normally they would just see a static page without frames.
So, how do we get that static source page to come up in the main frameset?
We perform this task by placing a simple block of Javascript in the head section of each page of our website.
Then when someone directly accesses the source page it will redirect to the main frameset page.
The Code
Paste this JavaScript code into the HEAD section of your main frameset page:
(Name your main frameset page index.html)
<script language="javascript" type="text/javascript">
var fname="content"; //Your main content window 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 adjust the name of your main content window.
Paste this code into the HEAD section of your navigation page and other utility pages.
<script language="javascript" type="text/javascript">
if(self.location==top.location)self.location="index.html";
</script>
Paste this JavaScript code into the HEAD section of all your content pages.
(Place name of content page after question mark)
<script language="javascript" type="text/javascript">
if(self.location==top.location)self.location="index.html?page2.html";
</script>
For more information on using this technique see How to Create a website with Frames. Study the lesson on Redirection.
Net Success 2000 Plus Inc
Po Box 1508
Somerset KY 42502
Copyright 2007-2011
Last Modified: January 15, 2011
Create a Website Home