Frameset Manager

Many people have problems with frames when used in the creation of a website. One of the major bugbears for users is that they can't bookmark an exact page within a frameset and simply get continually returned to the initial frameset. To resolve this, they bookmark an individual frame, and in doing so lose the relationship to the other frames which generally provide navigational aids within the site's content.

Previously, a well know javascript was used that simply checked to see if the current page - the one that is a frame - was the top level page, while this provides a mechanism to identify a frame without the supporting pages, it was often resolved simply by redirecting to the correct frameset, which also meant that the page being looked at was lost and replaced with the default page of the frameset, the code is below and a demo is also available :

<script language="javascript">
if (document.location == top.location)
{
    document.location="frameset.html";
}
</script>

The solution presented here allows the user to bookmark any page within the frameset that they wish. However, when that page is loaded up it will check for its parent frameset and if not present, it will offer the user the option to have the page redisplayed with the correct surrounding frames. This is achieved by passing the URL of the page to the framebuilder page which can then create a frameset with the file in the appropriate place.

Simply add the Javascript shown below into the page of your framset.

<script language="Javascript">
var frame_builder = 'index.html'
if (top.document == self.document)
{
    if (confirm('This page is normally in a frameset. Do you wish to load it in context?'))
    {
        window.location = frame_builder +'?'+ window.location.pathname
    }
}
</script>

Then amend your frame builder page as follows :

<script language="Javascript">
var thatframe = 'somepage.html'
if (location.search)
{
    var thatframe = (location.search.substring(1,location.search.length))
}
var frameset = '<FRAMESET ROWS="50%,50%">'+'<FRAMESET COLS="100%">'+'<FRAME NAME="thisframe" SRC="somepage.html" MARGINHEIGHT=0 MARGINWIDTH=0 SCROLLING=AUTO NORESIZE>'
+'<FRAMESET COLS="100%">'+'<FRAME NAME="thatframe" SRC= "'+ thatframe +'" MARGINHEIGHT=0 MARGINWIDTH=0 SCROLLING=AUTO NORESIZE>'
+'</FRAMESET>'
document.write(frameset)
</script>

A demonstration page showing this revised version is available.

If you want the redirect not to ask the user to confirm, then simply remove the following :

    if (confirm('This page is normally in a frameset. Do you wish to load it in context?'))
    {
        window.location = frame_builder +'?'+ window.location.pathname
    }

Simply leaving the line - window.location = frame_builder +'?'+ window.location.pathname does the redirect to the frame builder page without any user interaction. A demonstration of this approach is also available.
Website Designed by Adservio Consulting Valid HTML 4.01 Strict    Valid CSS!    Level A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0