A number of search engines (including Google) now happily index the content pages from within a frameset. This means that when a searcher clicks on a link from the search engine, they arrive at the content page devoid of its navigation and other important elements. Is there a clever javascript (or other) method of detecting if a page is missing its frame and then force it to display back within its frameset?
Announcement
Collapse
No announcement yet.
How to put a page back in its frameset?
Collapse
X
-
1. stick a redirect into the <head> of the content page (content.html) like this:
Code:<script language=javascript> <!-- window.location="[b]frameset.html?[i]content.html[/i][/b]" //--> </script>
Code:<script language=javascript> <!-- window.[b]mainframe[/b].location = window.location.search.substr(1) //--> </script>
this means that when anyone stumbles across content.html they will be sent to frameset.html and 'content.html' will be sent in the location.search (the bit in the address starting with a '?'. when frameset.html opens, the bit after the '?' ('content.html') is loaded into the mainframe.
ok?neil.c
-
you're on the right track, neil, but you forgot a couple of details. what happens if you don't have any extra information appened to the url?
i'll copy and paste my script from the old forum here:
anything in bold, you have to change to fit your site.
this first part goes in the page, where you create your frames. ie, frames.htm
<SCRIPT>
function frame_saver()
{
if (self.location.search)
{
self.FRAMENAME.location = "http://www.DOMAIN.com" + self.location.search.slice(1);
}
}
self.onload = frame_saver;
</SCRIPT>
this second bit goes in any frames that don't change, like frames you use for navigation.
<SCRIPT>
if (self == top) {self.location = "http://www.DOMAIN.com/frames.htm"; }
</SCRIPT>
this last part goes in all of the pages that are in the main frame; the ones that you want to be able to bookmark.
<SCRIPT>
if (self == top)
{
var url = self.location.pathname;
self.location = "http://www.DOMAIN.com/frames.html?" + url;
}
</SCRIPT>
Comment
Comment