Forum Moderators: open

Message Too Old, No Replies

google and frames

         

nadsab

6:05 am on Apr 9, 2003 (gmt 0)

10+ Year Member



I have a site with frames. Google is indexing the main page OK and that comes up fine, but it is also indexing pages that the frameset calls separately, without the frames, so there are some URL's in google index to pages that can not be viewed properly without the frames.

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.

johannes

6:21 am on Apr 9, 2003 (gmt 0)

10+ Year Member



One solution is javascript. I think this script is cross-browser compliant.

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?

nadsab

6:39 am on Apr 9, 2003 (gmt 0)

10+ Year Member



Thanks johannes,

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?

Pegasus

7:44 am on Apr 9, 2003 (gmt 0)

10+ Year Member



I have a better answer:

Don't use frames :)

They're not good for man or beast

killroy

7:57 am on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been running a DB driven site with frames for a few years. Google indexes 10s of 1000s of internal pages, all are ranked niecly and my code cleans up the frames pronto. visitors don'T even notice anything amiss.

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

johannes

8:02 am on Apr 9, 2003 (gmt 0)

10+ Year Member



Sorry nadsab, I didn't give you all. It was a long time I used this script :)

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.

nadsab

2:20 pm on Apr 9, 2003 (gmt 0)

10+ Year Member



OK johannes

your second script goes into index.htm, so does the first script go into one of the frame pages?

nadsab

2:24 pm on Apr 9, 2003 (gmt 0)

10+ Year Member



Kilroy,

your script, does that go between the head tags? and inside script tags? On index.html or, on the actual frame pages? Also, any substitutions?

Thanx.

nadsab

9:35 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



Anyone got any suggestions on this one? :)

killroy

9:46 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The JS goes into the <head> of the content page. but you need a server side script that'll built the frameset (at least that'S waht I use) but you could also use hte document.write technique mentioned above.

SN