|Java menu knowledge base|
- A frame doesn't hurt - provided you use it well
There are good frames and bad frames. Generally, the web has come to accept
that a division into two frames, one of which is a narrow strip for navigation,
is a good thing. Frames are used badly when used (a) without sufficient reason,
(b) without regard for small 640 x 480 screens, (c) in large numbers, (d) without
regard for clarity and convenience of site use. Provided you keep to a maximum of
two, have a good reason (i.e. navigation), test your site on a 640 x 480 screen,
and ensure that the result is clear and convenient - then you have used frames well.
- Advantages and disadvantages of frame navigation
If you use a navigation frame, you only need one navigation file for your
entire website. Then you can forget the navigation problem and concentrate
on actual content when writing all the other files. Moreover, when you come
to update your site, only one navigation element has to be changed. If your navigation
is spread over every single page (because you didn't have a navigation frame),
then the addition of another page or section means every single page has to be updated again.
There are many disadvantages of frames, but all of these can be overcome with
the right tricks. Again, it is a question of bad frames and good frames. Make
sure you use the latter.
The disadvantages: (i) ugly dividing lines and scroll bars across the middle of the screen,
(ii) too little space left for content, (iii) someone accidentally gets out of
the frame system and can't navigate any more, (iv) other people's pages get
loaded into your own frame system. All of these disadvantages can be avoided,
as the following tips and tricks explain. Back in 1996, there was also the
disadvantage that some people still had really old browsers which didn't support
frames. Well, even then there is the noframes tag which allows you to specify
special pages for such browsers - if there are any left.
- Search engines and frames
Did someone tell you that Google can't see inside your frames and index your
Not true! Many years ago, at the beginning of the web, search engines had
some difficulty with frames. These days, search engines see everything. Google
sees inside PDF's, DOC's, many types of dynamically generated pages and many
places you would never have expected. Frames
are easy for it.
- Some complete HTML code for a good navigation frame
This observes a number of important points, including (i) getting rid of the ugly dividing lines between frames, (ii) using a fixed size for the navigation frame, (iii) using cross-browser code for getting rid of margins and positioning page elements right up to the frame edge.
<FRAMESET cols="110,*" border="0" framespacing="0" frameborder="0">
<FRAME SRC="menu.html" NORESIZE scrolling="No"
<FRAME SRC="welcome.html" NAME="main" NORESIZE scrolling="Auto"
[Insert code for non-frames browsers here]
- A strategy to ensure the navigation frame is always present and ensure that search engines catalogue your site properly
code always executes when a page is loaded.
my_frames_page = "frames.html";
top_page = top.location.toString().toLowerCase();
top.location = my_frames_page;
The file "frames.html" should contain the frames setup HTML code with
the FRAMES tags (see above). This script will always load your pages
into the frameset if they are not in it.
The search engine trick is this: when you register your site, or
give away your URL to others, don't tell them the URL of your
frames page - tell them the URL of your main content page. The
search engine won't run the script loading the frames, so it will
read your main content page and properly index your website. You
should, of course, ensure that your main content page has a small
list of non-java URL's at the bottom which link to all the key
pages in the rest of your site - so that the search engine can
- How to target frames properly
There are a great many reasons why some designers
end up with an applet that doesn't seem to be targeting
frames. Instead the applet opens pages in a new window.
Almost all the causes lie with incorrect HTML. The cause
in your case may be any one of the following.
Cause 1: not specifying a frame in the index file
In the applet's index file a targeted link has the syntax
"LINK:myPage.htm,myFrame". Note the comma, followed by the
name of your frame. BTW, if you haven't read this, please
read it now!
Cause 2: not naming the frame in advance of targeting
You must write
<FRAME SRC="myPage.htm" NAME="main" ....>
in the FRAMESET page. The name attribute sets the name of
Cause 3: not supplying a source file when naming the frame
The following does not work in recent Netscape versions:
<FRAME NAME="main" ....>
because no SRC page is specified. The result is that the frame
name is ignored by the browser and pages targeted to "main" open
in a new window. Solution: specify a dummy SRC file.
Cause 4: using an absolute URL for a local file
Recent versions of Netscape (4.5+?) (and possibly IE5+)
tend to load absolute URL's into new windows under certain
circumstances. So specify your URL's as relative ones if
you possibly can.
Cause 5: user configured browser not to target frames
Recent browser versions have vastly enhanced user-configuration
options which enable your site visitors to dictate a great many
factors affecting how they see your webpages. These now also
include factors affecting the circumstances under which new pages
are loaded into frames or new windows. If particular users of your
site report franme-targeting problems, this may be their own fault
for configuring their browsers like that.
Cause 6: trying to be too clever with frame names
Frame names can theoretically be changed after initialisation
applet will only be able to target frames under the names that
existed when the frame was created, or the name that was used
in the original FRAMESET tags. It may not be able to track later
Cause 7: unwittingly letting your web design programme
write target manipulation code
Many recent web design programmes tend to write in
tags and attributes that force a default target frame
(e.g. TARGET='myFrame' attached to some HTML tag such
as BASE, FRAME, APPLET, etc). We have
had cases where clients have said that this was the cause of
page mis-direction, although we have not been able to
verify this. Solution: load your HTML pages into
a text editor and remove these bits of code.
Cause 8: complex server aliases
We have had a case where complex server aliases caused
serious browser- and OS-specific frame targeting problems.
This might be associated with cause 4 (above) and with
use of the CODEBASE attribute in the APPLET tag.
Cause 9: duplicated frame names across multiple windows
We have a report of frame loading problems with some Microsoft
VM's (but not all) when a number of windows are open at the
same time, some of which contain framesets using non-unique
naming conventions. Solution: if you must use multiple windows
on your website, use unique frame names.
If you are tempted to think that an applet has caused a
frame targeting problem, consider the following. The java
command for loading a page into a frame is very simple -
it is: showDocument(url,frame). This is about as
simple and standard as an HTML <A HREF="...." TARGET="....">
tag. All our applets use this code. It's too simple to
get wrong. The problems sometimes occur before the URL and frame
get into the applet (e.g. in your index file), and mostly
occur after the URL and frame exit from the applet and are
processed by the browser (i.e. the browser gets confused by your
HTML or something).