Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Frame | Q317 [ previous next ]

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

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');
//--></SCRIPT>

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

<HTML>
<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">');
document.write('<\/FRAMESET>');
//--></SCRIPT>
</HTML>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.