Good HTML Frames

Updated: Nov 21.2005

Most of the time when you read about HTML frames online, you basically are discouraged from using them. One of the main reasnos is because of navigation. Normally people use frames to separate their navigation menu from their page contents. If a search engine or another webpage links direectly to one of your content pages, you lose the navigation frame and the user can't get around. I found this handy dandy javascript a while back. This is taken from another webpage:
I just wanted to make a copy to spread the joy and to make sure I don't lose it. I also made a small modification so the code would be easier to copy and paste.

Basically, if someone loads a content page directly, it redirects and opens it with the navigation menu and corresponding content page. This is UNlike other scripts that boot you back to the mainpage when giving you back the navigation menu. If you need a better explanation go here. But do note that my modification improves on his script.

Paste this JavaScript code into the HEAD section of your index page (the page that sets up the framesets). Don't forget to adjust the frame name in the script!

<script language="javascript">
var fname="content"; //MAIN CONTENT AREA FRAME **NAME**

Paste this JavaScript code into the HEAD section of all your content pages. Do not paste this code into the index page or your navigation page.

<script language="javascript">
var fname=self.location; if(self.location==top.location)self.location="index.html?"+fname; </script>

Paste this JavaScript code into the HEAD section of your navigation page. There are no settings to adjust in this one.

<script language="javascript">

Go back