DelphiFAQ Home Search:
General :: Web publishing :: JavaScript :: Document


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Force a page to always appear in a FRAMESET


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>';

Generated 16:02:19 on Jul 20, 2017