Finding Parents for Orphaned Pages
Keep your frame content pages from being left "orphaned", that is, being viewed without the accompanying frameset. An orphaned page can be a real downer for your visitor, because usually in a frame-based site items such as navigation menus and headers are found in other frames. If a page loads by itself, without these items, then your visitor is left stranded, and will probably just go somewhere else. Now this is a good argument for not using frames, however there are instances where frames may provide a solution to a problem.
The first thing you'll need on each child page (the page that display's inside the frameset), is a check to see if it is missing the frameset page. If the frameset is missing then we need to redirect to the main page, and pass it the URL of the child page for display. To do this, add the following to the <HEAD> section of each page:
<script language="javascript" type="text/javascript">
<!--
if (top.location == self.location) { //if page is not in its frameset
top.location.href = "http://www.domainname.com/frameset.html" + "?" + window.location.href;
}
//-->
</script>
If the child page is not in the frameset, you'll see that the top window is re-directed to the frameset page and a "?" plus the current page URL is appended to the end of the frameset URL. This is known as a "GET" or passing the query string.
Now, we'll also need to put a script in the parent page to help it "parse", or decode, the query string it was sent so that it can load the correct page. We'll also need to include a default page to load, just in case there is no query string sent. To do this, place the following script in your frameset page <HEAD> section:
<script language="javascript" type="text/javascript">
<!--
pageURL = "DEFAULTPAGE.HTML";
if (parent.document.URL) {
parentURL = parent.document.URL;
if (parentURL.indexOf('?') != -1) {
pageURL = parentURL.substring(parentURL.indexOf('?')+1,parentURL.length);
}
}
function fillFrame() {
parent.main.location.href = pageURL;
}
//-->
</SCRIPT>
All that's left is to tell the frameset to execute the fillFrame() function when it loads. To do this, put a JavaScript event handler into your frameset HTML like the example below:
<frameset cols="150,*" border="1" frameborder="1" framespacing="1" bordercolor="#000000">
<frame name="menu" src="side.html" scrolling="no" noresize marginheight="10" marginwidth="10">
<frameset rows="100,*,100" onLoad="fillFrame();" border="1" frameborder="1" framespacing="1" bordercolor="#000000">
<frame name="top" src="top.html" scrolling="no" noresize marginheight="10" marginwidth="10">
<frame name="main" src="javascript:parent.blank" scrolling="auto" noresize marginheight="10" marginwidth="10">
<frame name="bottom" src="bottom.html" scrolling="no" noresize marginheight="10" marginwidth="10">
</frameset>
</frameset>
My3C's
perrychicker
Back | Tell A Friend | Search this Site
© 1998 - 2010 psacake.com
Version 3.23
Send me One Million FREE Guaranteed Visitors