Google Answers Logo
View Question
 
Q: Website - directing people from an individual frame to the main frameset page ( Answered 5 out of 5 stars,   4 Comments )
Question  
Subject: Website - directing people from an individual frame to the main frameset page
Category: Computers > Internet
Asked by: bonnington-ga
List Price: $5.00
Posted: 27 May 2002 12:07 PDT
Expires: 26 Jun 2002 12:07 PDT
Question ID: 18315
My site is listed with Google, and I have built it using frames, ie.
the main page, www.JamesSchumann.com, is a frameset containing 2
frames within it. I find that sometimes Google lists in its directory
one of the individual frames rather than the main frameset, eg.
www.JamesSchumann.com/CV/CV.html. When someone clicks on this link,
that individual frame gets loaded onto the entire screen rather than
the frameset being loaded. Is there any way to make it so that if
someone tries to load this individual frames, they get redirected to
the main frameset page? Someone told me a way of setting up a 'ghost'
version of my website so that people going to an individual frame will
be sent back to the main frameset, but this is not really what I am
after. I also know that I could take the META tages off the individual
frames and then it might not be listed anymore, but I want to still be
able to put META tages on all the frames.

I am looking for perhaps some HTML code that will direct people from
an individual frame to the to the main frameset, but still allow the
individual frames to be loaded properly within the frameset page. I
would need to know exactly what code to use and where to put it.
Answer  
Subject: Re: Website - directing people from an individual frame to the main frameset page
Answered By: j_philipp-ga on 27 May 2002 14:42 PDT
Rated:5 out of 5 stars
 
Hello,

To check if a page is called without the frameset, and to redirect to
the homepage, you can put the following JavaScript in the HTML page:

----------------
...
<head>
...
<script type="text/javascript"><!--
function checkFrameset()
{
    if (top == self)
    {
        top.location.href = "http://www.JamesSchumann.com";
    }
}
// --></script>
</head>
<body onload="checkFrameset()">
...
----------------

However, you should know that this has side-effects:
- it only works if JavaScript is enabled
- it will confuse the browser history (like when you click "Back")
- it will take the page a bit longer to load
- it will not immediately show the content the search engine indexed

A very good alternative to all this is to include whatever part of the
site is constant (e.g. the navigation) on the server using server-side
scripting.
In that case, there's still only a single file containing the static
part, but before the content is served to the client it gets merged
with it. I can clarify this solution if needed, but for that it's
important to know which scripting your server supports (like PHP,
Python, ASP).

Another option is to include the static navigation in all HTML files.
You can update it using local search-and-replace.

On a sidenote, if you keep with the frames solution: it will help some
visitors and search engines if you put a <noframes>...</noframes>
section in the framesetting page.
Also see W3C on "noframes":
http://www.w3.org/TR/REC-html40/present/frames.html#h-16.4.1

I hope this helps!

Request for Answer Clarification by bonnington-ga on 30 May 2002 09:07 PDT
Firstly, thank you to the answerer and commenters. I haven't used this
service before, and was overwhelmed by the number and extent of
responses!

1 I inserted the javascript listed in the first answer, and it worked
fine, though as you mentioned it may be annoying for someone when the
Back button doesnt work.

2 Re: server-side scripting - this is completely new to me, and I
would like to know where I can find out more about this. Do you mean
that, say, the menu bar could be on the screen all the time and pages
just load around it? I am emailing my server to find out what
scripting the server supports. If it is any help, my server is Titan
Internet, at www.titanhosts.net.

3 Re: the last Comment, by mach-ga. Thank you for the web reference; I
have tried to insert this java code into my site but cannot get it to
work. The example on the website seems to be for 3 (nested) frames,
and as I have only 2 frames, I have simplified the code.

In the frameset page (index.html) , I added the following:

<html>
<head>
.
.
.

<script language ="Javascript"
<!--

var ar0 = "contents/contents.html"
var ar1 = "CV/CV.html"

var str = location.search;
var pos = str.indexOf("&");
if (pos !=-1) {
  var num = str.substring(pos + 1, str.length);
  window ["ar" + num] = str.substring(1, pos);
}

// -->
</SCRIPT>
</head>

<script language="Javascript">
<!--

document.write (

'<frameset cols="150,*" rows="*" bordercolor="#FFFFF"
frameborder="NO">',
  '<frame name="index" bordercolor="#CC3333" scrolling="AUTO" src="',
ar0, '">',
  '<frame name="body" src="', ar1, '" scrolling="AUTO">',
'<frameset>'
);

// -->
</script>
</html>


ie I just used 2 variables, ar0 and ar1 in the code given.

There may be the odd typo in this as it has all been typed in again!

This is where 'index' and 'body' are the 2 frames, each initally
containg the pages contents.html and CV.html respectively. Each page
is stored in the folders Contents and CV respectively on the server.

Then for one of the pages, biography.html (stored in the folder
'biography' on the server) I added the other code in the HEAD section:

<script language="JavaScript">
<!--

if (top.location.href.indexOf("index.html") == -1)
  top.location.href = "index.html?biography/biography.html&1";

// -->

</script>

I wasnt sure whether I should put in biography.html ot
biography/biography.html for the variable 'pageURL'.

When I tried this I had the following problems:

a. Although the frameset looked OK online, when viewed in Dreamweaver
there was just a  blank page

b. When, with the main frameset page on view (www.JamesSchumann.com),
I clicked on the link to load up the 'biography' page into the
frameset, rather than just loading this frame into the frameset it
tried to reload the whole frameset (i.e. as if I had tried to load the
biography frame onto the whole screen rather than into the frameset)

c. When it did try to reload the frameset as described above, it got
the address wrong. It went to the page:
http://www.JamesSchumann.com/Biography/index.html?biography/biography.html&1

whereas if it had said

http://www.JamesSchumann.com/index.html?biography/biography.html&1 it
would get to the right page.

You can see this in action by going to my web page and clicking on the
'biography' button.

I think the problem is that I am storing each different frame in a
different folder?

So to recap - it is reloading a frameset when it doesn't need to and
there is a problem caused by my folders.

Hope this is clear enough to deal with.

James

Clarification of Answer by j_philipp-ga on 30 May 2002 09:58 PDT
Hello again,

To your question regarding server-side scripting:
I checked out titanhosts.net, but they offer a variety of server
operating systems, running different scripting languages. You could
implement the solution in PHP, Python, ASP (VBScript/ JScript) and
other languages, depending on what they will tell you on your
server-type. PHP is a very likely option these days.

--> Now what is server-side scripting?

Instead of dynamically creating content on the client-side (in the
browser, after the files have been served) -- where you need to rely
on JavaScript bein enabled, and have to make sure your script works in
every browser -- you dynamically prepare the content on the server.
What is served to the client then looks and behaves just like static
HTML (or images, or stylesheets), but was in fact created using one of
the above-mentioned scripting languages. No trouble for exotic
browsers, JavaScript-disabled browsers, or any search-engines!

--> Will the content just "load around it" and the navigation be
static?

Not exactly -- the content and the navigation will be rebuild and
served as whole everytime the user requests a new page. However, since
the navigation might be positioned at the same place (e.g. using CSS,
or any other layout mechanism), this is not much of a difference to
the end-user. Also, using stylesheets, you can cache the layout
information to make sure it's not resend every time for every new
page.


As to your solution to dynamically write the frameset on the
client-side using JavaScript, personally I would absolutely argue
against doing that; it should make it hard for search-engines to
follow to any of the contentual pages, thereby excluding your web site
from many people trying to find it.


Where to get more information on server-side scripting:

PHP homepage:
http://www.php.net

Python help:
http://www.python.org/Help.html

ASP (VBS, JS) at the Microsoft Scripting homepage:
http://msdn.microsoft.com/scripting/

SSI (Server Side Includes) Tutorial at UseForSite:
http://www.useforesite.com/tut_ssi.shtml


Hope this helps!
bonnington-ga rated this answer:5 out of 5 stars
Thank you, detailed answers - but making me realise I am a bit out of my depth!

Comments  
Subject: Re: Website - directing people from an individual frame to the main frameset pag
From: zzen-ga on 27 May 2002 15:14 PDT
 
There is another workaround, but it should be noted I do not really
recommend it. I supply it only to give you the choice:

If the frames are a integral feature of the page and cannot be easily
eliminated via server-side inclusion of common navigation and such (as
described above), you can keep your frames and still make Google point
users correctly to the whole framesets:

for EACH page of your site, you need to make a frameset document,
which has the common part (navigation etc.) as one of its frames and
the frame with the corresponding content as the other frame. For
example, if you have a current site which looks like this:

index.html (the frameset page)
navigation.html (the "common frame")
foo.html
bar.html
contacts.html (these three are pages displayed in the content frame)

Then you might rework your site as follows:

index.html
navigation.html
f_foo.html
foo.html
f_bar.html
bar.html
f_contacts.html
contacts.html

Where each f_*.html file is a frameset document with the first frame
navigation.html and second frame corresponding *.html file.

Then, all your LINKS inside your site should be replaced as follows:

<A HREF="foo.html"> becomes <A HREF="f_foo.html" TARGET="_top">.


The positive effects:
each content page has now its own unique frameset page and you link
only to the frameset pages. Thus, Google bot will also collect only
links to FRAMESET pages and clients will be pointed to the correct
content page and still have all the framesets displayed.



A second alternative (modification of the above answer about
JavaScript redirects) is to programm a server-side script (PHP, Perl),
which supplies the frameset document and dynamicly substitutes the
address of the second frame for the address from which the client was
redirected to this page (that's called the REFERRER and is available
in the HTTP header file sent with each request). The script would then
check:

*) if the REFERRER comes from your site or from elsewhere

and do one of the two actions based on the result

a) if the REFERRER comes from elsewhere, the send out the plain
frameset document with "default" content frame (as in index.html or
simillar)

b) if the REFERRER comes from your site, substitute the address of the
content frame in the frameset document for the address of the
referrer.

This has basically no sideeffects (not counting those which were
mentioned in the previous answer) and enables the client to
transparently recieve the requested content page with the frame
supplied around it. Also - no changes to links in the site are
required - only add the PHP script and point all javascript redirects
mentioned in the previous answer to this script. If more info is
needed, I will happily supply.
Subject: Re: Website - directing people from an individual frame to the main frameset page
From: budsmith-ga on 27 May 2002 23:23 PDT
 
A quick solution is to add a Home link on all your content frames.
That way the user who finds your frame in Google search can quickly
get to your home page, then use navigation or site search (if you have
it) to get back to the content they want - with the whole frameset,
this time.

More complicated is to use the solution you got in the answer, but
also to have a separate frameset and slightly different JavaScript for
each content page. That way you can call the right frameset, instead
of the home page, from each target frame that gets pulled up by
itself.
Subject: Re: Website - directing people from an individual frame to the main frameset page
From: budsmith-ga on 27 May 2002 23:25 PDT
 
For details on how to implement the solution I mentioned, check out
this Jakob Nielsen article:

http://useit.mondosearch.com/cgi-bin/MsmGo.exe?grab_id=3417176&EXTRA_ARG=&host_id=2&page_id=122&query=frames&hiword=FRAMES+FRAME+FRAMESET+FRAMED+FRAMEBASED+FRAMELESS+
Subject: Re: Website - directing people from an individual frame to the main frameset pag
From: mach-ga on 28 May 2002 15:05 PDT
 
The problem with all the above solutions is that none of them actually
direct the user to the page that they are viewing with the
navigational bar (the other frame).  Embedding this little script will
bring the user to a page with the correct frames.  This page tells how
to implement a _full_ solution:
< http://www.webreference.com/js/column36/forcing.html >If you need
help just post something on this thread and I'll help you with it.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy