DelphiFAQ Home Search:

Force a page to always appear in a FRAMESET


commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.


Our site uses a horizontal frame at the top for navigation. So even if people visited my page through a direct link e.g. from the search engine Google, I want the page to appear in that frameset. How should I do this?


You check to find out that a page is not framed and then you load the desired frameset:
if (top == window) top.location.href = 'frameset.html';

You can even pass the frame url in the query string e.g.
if (top == window) top.location.href =
'frameset.html?' + escape(window.location.href);

This line has to be in every to-be-framed document on your site.

Then in the main frame page - let's call it frameset.html - you read the query string to get the frame url and afterwards you document.write the frameset. The example below shows how such a Frameset.html file would look like.

// Frameset.html:

var url = ?
  unescape( :
var html = '';
html += '<FRAMESET ROWS="150, *">';
html += '<FRAME NAME="navBar" SRC="navBar.html">';
html += '<FRAME NAME="content" SRC="' + url + '">';
html += '</FRAMESET>';




NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: