Forum Moderators: open
How can I fix this? I can't use a robots.txt file to exclude the pages that are supposed to be inserted into the frames from indexing, because if I do that, they won't show up in the frame. But if I leave the orphaned pages in the index by themselves, and if people go to those pages instead of index.html, they won't view those pages properly.
Put this in the header, or external js file:
function checkframe(){
if (document.layers && (self.innerHeight == 0 && self.innerWidth == 0)) return;
if (top == self ¦¦ (parent.frames[1].name!= 'YOUR FRAME NAME')){
if (document.images)
top.location.replace('index.html?' + location.href);
else
top.location.href = 'index.html?' + location.href;
}
} Put this in the body tag.
<body onload="checkframe()">
This is the main reason I don't use frames. I think they are wonderful, but if you get referrals from a SE to the frame and not the frameset, you have to make something like this. It works, but it's not so elegant. Maybe someone has a better solution?
the code works, kind of. When I go to the orphaned page it does not show up as orphaned any more, the frame shows up, but the page that is supposed to be in the frames is not there either. It's just blank.
It did not work until I placed the code inside of <script></script> tags inside the <head></head> tags. WIthout the script tags the actual java script was superimposed upon the web page when viewing.
Am I supposed to make substitutions for 'YOUR FRAME NAME', top.location.href, etc?
if(top.location==document.location)top.location=
'framescript?page=mainframeinnerpage'
the framescript then builds the standard frameset, looking at the page parameter for what it should place in the main frame (loading he standard meanus and header in the others)
It's not the best solution but works well. And since my main inner pages are linked well google spiders the whole site (so do all the other bots) and I don't really have any problems with unindexable pages.
SN
You have to place this in your index.html file as well:
if (top!= self){
if (document.images)
top.location.replace(location.href);
else
top.location.href = location.href;
}
else {
document.write('<frameset cols="150,*" border=0>');
document.write('<frame src="FRAME1 filename" scrolling="auto">');
document.write('<frame name="YOUR FRAME NAME" src="' + (location.search? unescape(location.search.substring(1)):'FRAME2 default filename') + '">');
document.write('<\/frameset>');
} You have to make some replacements, experiment.
YOUR FRAME NAME means what you place in TARGET=
You should replace index.html if that is not your default frameset page.