Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search engines only linking to one frame.

Status
Not open for further replies.

KnudNexo

IS-IT--Management
Jul 16, 2001
5
AU
I have a page with frames.
I like that my page shows up quite well in most search engines but when you follow a link from most search engines to my site only the page with the content is loaded. Not the other frames.
Is there a way to get my frames to load up when these links are followed?
I still want search engines to be able to see the content for my site.
What is the best solution to my problem.
 
Hi KnudNexo,

This is what I use for my homepage (the version I'm talking about isnt uploaded yet).

The files that are not supposed to be outside the frame must have this script:

<script language=&quot;JavaScript&quot;>
<!--
onload=function(){
var thisLocation = document.location;
if( document.location == top.location ) {
top.location.replace(&quot;Help.htm&quot;);
top.document.cookie = &quot;content=&quot; +thisLocation;
}
}
//-->
</script>

and in the main frameset put this script:

<script language=&quot;JavaScript&quot;>
<!--

function getCookieVal(offset) {
var endstr=document.cookie.indexOf(&quot;;&quot;,offset);
if (endstr==-1)endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie(name) {
var arg=name+&quot;=&quot;;
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while(i<clen){
var j=i+alen;
if(document.cookie.substring(i,j)==arg)return getCookieVal(j);
i=document.cookie.indexOf(&quot; &quot;,i)+1;
if(i==0)break;
}
return null;
}


var contentCookie = GetCookie(&quot;content&quot;);
var contentDest = &quot;HelpSplash.htm&quot;;

if( (contentCookie != null) && (contentCookie.indexOf(&quot;htm&quot;) != -1) ) {
document.cookie = &quot;content=&quot;; // Wipe out the cookie
contentDest = contentCookie;
}

var str=&quot;&quot;;
str+=&quot;<FRAMESET ROWS=\&quot;43px,*\&quot; BORDER=\&quot;0\&quot; FRAMESPACING=\&quot;0\&quot; FRAMEBORDER=\&quot;0\&quot;>&quot;;
str+=&quot;<FRAME SRC=\&quot;file.html\&quot; ID=\&quot;menufr\&quot; NAME=\&quot;menufr\&quot; FRAMEBORDER=\&quot;0\&quot; NORESIZE MARGINHEIGHT=\&quot;0\&quot; MARGINWIDTH=\&quot;0\&quot;>&quot;;
str+=&quot;<FRAME SRC=\&quot;&quot;+contentDest+&quot;\&quot; ID=\&quot;contentfr\&quot; NAME=\&quot;contentfr\&quot; FRAMEBORDER=\&quot;0\&quot; MARGINHEIGHT=\&quot;0\&quot; MARGINWIDTH=\&quot;0\&quot; SCROLLING=\&quot;yes\&quot;>&quot;;
str+=&quot;</FRAMESET>&quot;;
str+=&quot;<NOFRAMES><BODY></BODY></NOFRAMES>&quot;;
document.write(str);

//-->
</script>

Like magic :)
BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Bobbafet this is just the sort of thing I'm after, but I can only get this to work for htm pages.
The main content for my site is from a perl script. I have addresses like

and
clicking on either of these links will open the page but not inside the frames of the rest of the site. If I add your Javascript, it loads the frames but cannot reconise the &quot;.pl&quot; I think because it just loads the default content page.

how can I adjust this javascript to include the whole content &quot;display.pl?display=main&quot;

also do you know if search engines will still be able to index my pages with this javascript running?
 
yes, they can index any page on your site, but as far as
the &quot;display.pl?display=main&quot; is concerned, i haven't got a clue on how to that. This script was written for straight HTML, but what you could try is hardcoding the thisLocation variable for each page. So instead of using :

var thisLocation = document.location;

you could try this:

var thisLocation = '
I hope this helps,
BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
this means mean you'll have to hardcode it for every framed page. I dont know of any other way to do it.
BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
If i understand the posts I just read, you have a script named display.pl that you could modify to generate a framset, one frame always having the same thing in it (a footer or a navigation bar, whatever - it doesn't matter) and the other frame having whatever the ?display=_______ is? Just hard code the nav or the footer into your script and your current links would work fine, whats the problem?

Sample display.pl:
Code:
my ($url) = $in{'display'};
$url .= &quot;.html&quot;;

print &quot;Content-type: text/html\n\n&quot;;
print <<HTML;
<html>
<head>
<title>Your Page Title Here</title>
</head>
<frameset rows=&quot;150,*&quot;>
<frame name=&quot;top&quot; src=&quot;[URL unfurl="true"]http://www.domain.com/top.html&quot;[/URL] scrolling=&quot;no&quot; frameborder=&quot;0&quot;>
<frameset cols=&quot;150,*&quot;>
	<frame name=&quot;leftframe&quot; src=&quot;[URL unfurl="true"]http://www.domain.com/navigation.html&quot;[/URL] scrolling=&quot;no&quot; frameborder=&quot;0&quot;>
	<frame name=&quot;rightframe&quot; src=
Code:
$url
Code:
 scrolling=&quot;auto&quot; frameborder=&quot;0&quot;>
</frameset>
</frameset>

<noframes>
	<center><b>[ <a href=
Code:
$url
Code:
>Your browser doesn't support frames. Click here to continue</a> ]</b></center>
</noframes>

</body>
</html>
HTML
}

Could you modify this to do what u need? I can help you with your perl if you'll post the spot of code used to generate the frameset. -gerrygerry
Go To
 
This could also been done with js (and not with cookies).
Put this as an OnLoad in each of your pages (the ones generated by display.pl):
Code:
function checknav()
{
if (parent.location.href == self.location.href)
	{window.location.href = 'index.html?'+self.location.href;}
}

Put this as your index.html page:
Code:
<HTML>
<HEAD>
<script>
function fillFrame() {
var default_page = &quot;home.html&quot;;  // change to your default frame page

var content = (location.search) ? location.search.substring(1, location.search.length) : default_page;

parent.main.location.href = content;
}
</script>
</HEAD>
<frameset cols=&quot;150,*&quot; onLoad=&quot;fillFrame();&quot;>
  <frame name=&quot;toc&quot; scrolling=&quot;no&quot; noresize src=&quot;toc&quot;>
  <frame name=&quot;main&quot; src=&quot;loading.html&quot; scrolling=&quot;auto&quot;>
</frameset>
</HTML>

I threw this together so there may be a few errors (something from a site I made a while back - i may have accidentally cut out some lines) but give it a try anyway. -gerrygerry
Go To
 
Thanks GerryGerry and Bobbafet I have it working now

GerryGerry Here is what I did.
I made a new perlscript displayframes.pl as follows.


#########################################################

sub get_input {
# Get the input from the STDIN and ENV...
read(STDIN, $inbuffer, $ENV{'CONTENT_LENGTH'});
$qsbuffer = $ENV{'QUERY_STRING'};

foreach $buffer ($inbuffer,$qsbuffer) {

# Split the name/value pairs...
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value =~ s///g;

$value =~ s/~!/ ~!/g;

$value =~ s/<([^>]|\n)*>//g;
$FORM{$name} = $value;
}
}
}

#Body of perl script

&get_input;
use CGI;

$url = &quot;$FORM{'display'}&quot;;
if ($url eq &quot;&quot;) {
$url = &quot;main&quot;
}

print &quot;Content-type: text/html\n\n&quot;;
print <<HTML;
<html>

<head>
<title>Savannah Equipment Pty Ltd - $url</title>
</head>

<frameset framespacing=&quot;0&quot; border=&quot;false&quot; frameborder=&quot;0&quot; rows=&quot;40,*,40&quot;>
<frame name=&quot;rtop&quot; target=&quot;rmiddle&quot; src=&quot;../savannahaustralia/top_menu.htm&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot;
marginheight=&quot;0&quot; noresize>
<frameset cols=&quot;140,*&quot;>
<frame name=&quot;left&quot; src=&quot;../savannahaustralia/left_bar_buttons.htm&quot; target=&quot;rmiddle&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; noresize>
<frame name=&quot;rmiddle&quot; src=&quot;display.pl?display=$url&quot; target=&quot;_self&quot;>
</frameset>
<frame name=&quot;rbottom&quot; src=&quot;../savannahaustralia/bottom.htm&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot;
marginheight=&quot;0&quot; noresize target=&quot;rmiddle&quot;>

<noframes>
<body>
<center><b>[ <a href=display.pl?display=$url>Your browser doesn't support frames. Click here to continue</a> ]</b></center>
</body>
</noframes>
</frameset>
</html>
HTML

print <<EndFooter;
</body>
</html>
EndFooter
##########################################################


Then in my original display.pl I added the JS

##########################################################
print <<framejavascript;
<script language=&quot;JavaScript&quot;>
<!--
onload=function(){
if( document.location == top.location ) {
top.location.replace(&quot;displayframes.pl?display=$FORM{'display'}&quot;);
}
}
//-->
</script>
</head>
<body>
framejavascript
##########################################################

This all seems to work with the one small problem that When you open the display.pl not inside the frames it loads up completely before then loading up the frames. (only a small problem.) Thanks

here is a link to display.pl
 
Not a real problem it's just that the page fully loads up (on my browser anyway) before it switches to the framed version. I can live with it.
 
If you do you js in the very beginning, you should be ok... try this:
Code:
<html>
<head>
<script>
 if( document.location == top.location ) 
{top.location.replace(&quot;displayframes.pl?display=$FORM{'display'}&quot;);
</script>
</head>
<body>
...
-gerrygerry
Go To
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top