Here's the script that goes into your one home page, with comments:
<!-- The script below must be in the head section --> <!-- of your home page, as in this example --> <script language="javascript"> function fillMain() { //You must change page1.htm below to the name of the //to appear in your "main" frame normally. var defaultPage = "page1.htm" //Location.search isolates any text at beyond a question mark in a URL. passedName = location.search lengthOfPassedName=passedName.length //If a file name was passed, put that page in the main frame... if (lengthOfPassedName > 0) { parent.main.location.href=passedName.substring(1,lengthOfPassedName) }else{ //If no file name was passed, display the default page for the main frame. parent.main.location.href=defaultPage } } </script>
Here's the script that goes at the top if each page, whith more explanatory comments thrown in:
<!-- The script below is required in head of each page to be framed --> <script language="JavaScript"> //If there are no frames here already... if (parent.frames.length==0) { //...Pull the file name (e.g. page2.htm, page3.htm) off the end of the URL. spot=location.href.lastIndexOf("/") thisDoc=location.href.substr(spot+1,location.href.length) //Set the URL of the main frame to the default page, or passed file name page. //To use in your own site you must replace index.htm below with name of your //home page (the page on your site that contains the frameset and frame tags). location.href = "index.htm?"+thisDoc } </script>
That, in a nutshell, is how it all works.