Frames and Redirection
The source pages that are targeted into the frames of your website are just plain Ole HTML pages.
If these web pages are rich in content they will be indexed by Google and other search engines.
If someone clicks on the link to one of your source pages , all they would see is a plain Ole HTML page with no frames wrapper.
That's why we need redirection.
When a user clicks on the link to your page we want to redirect it to the frameset and have it appear in the content window.
The Code
We'll need 3 blocks of javascript to make our redirection scheme foolproof.
Main Frameset Page
Place this block of code in the head section of the main frameset page. You should name this page index.html
The code:
<script language="javascript" type="text/javascript">
var fname="content"; //CONTENT AREA 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>
Make sure that the text between the quotes in this line is the name you've given to your main content window:
var fname="content";
Utility Pages
Let's call pages like the header.html, footer.html and links.html pages utility pages.
If someone clicked a link or accessed these page directly, what would they see?
In the first case they'd see a page with the heading of our website. In the next 2 they'd see the footer of our site and then just the links.
We don't want people to access these pages directly but someone could.
We'll place a block of javascript in the head section of these pages that will redirect them to the main frameset and the default page will appear in the content window.
The code:
<script language="javascript" type="text/javascript">
if(self.location==top.location)self.location="index.html";
</script>
Paste this block of code in the head section of all your utility pages.
Content Pages
We could use the same block of javascript for our content pages and then just let people search for the page they actually accessed.
A better solution would be to send them to the main frameset and have the page they accessed appear in the main content window.
Let's change the last block of code ever so slightly and paste it into the head section of our content pages.
The code:
<script language="javascript" type="text/javascript">
if(self.location==top.location)self.location="index.html?nextpage.html";
</script>
Now if someone accessed this content page it would redirect to the main frameset and nextpage.html would appear in the content window.
Paste this block of code in the head section of all your content pages and change nextpage.html to the name of the content page.
If you don't get anything else from this website, Learn about redirecting directly accessed pages!