Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q317 How can I extend your redirecting access within frames article to use three frames?

You are here: irt.org | FAQ | JavaScript | Frame | Q317 [ previous next ]

If you want to ensure that the current document is loaded within a frameset, before a simple test to compare the top frame with the current frame, if they are the same then the document is not loaded in a frameset and you can change the location to pass the file to be loaded to another document that uses the required frameset. This is discussed in detail in the article Re-directing access within Frames #2. The following has been slightly improved over the original:

Place the following in the head section of your document:

<SCRIPT LANGUAGE="JavaScript"><!--
if (top == self)
    window.location.href = 'test.html' + '?' + escape('apage.html');

This will pass the encoded apage.html url to the test.html document, which then loads it into the required frame:

<SCRIPT LANGUAGE="JavaScript"><!--
document.write('<FRAMESET COLS="10%,20%,*">');
document.write('<FRAME SRC="contents.html" NAME="contents">');
document.write('<FRAME SRC="header.html" NAME="header">');
document.write('<FRAME SRC="' + (location.search ? unescape(location.search.substring(1)):'main.html') + '" NAME="main">');

©2018 Martin Webb