| |
Frames Frequently Asked Questions
- How do I update more than one frame at a time?
- How can I support non-frame browsers?
- Should I use the <BODY> tag inside the <NOFRAMES> tag?
- How do I validate my frames documents?
- How do I clear all the frames when going to a new URL? OR
How do I turn off frames when leaving my site?
- My pages open a new window instead of clearing frames
- How do I set the bg color for a specific frame?
- How can I print more than one frame in a screen?
- How do I sub-divide a frame?
- How do I use TARGET with a BASE/FORM/AREA tag?
- Can I remove frames but keep the current page?
- A back button within Frames
- Making Frames without Borders
- How do I turn off frames when entering my site?
- There's too much space on my framed pages OR
I can't get things aligned right on my framed pages
- Questions I haven't yet found answers to.
- For more information.
- How do I update more than one frame at a time?
There are at least 3 ways to do this:
- Use a <META... tag to load the second page.
The syntax is:
<META HTTP-EQUIV="Refresh" CONTENT="number of seconds to wait until refresh"
URL="page to update" TARGET="target frame">
- Javascript:
From the Javascript FAQ by Andy Augustine at
<http://www.freqgrafx.com/411/jsfaq.html>:
You can easily use this method to update any number of frames you choose. They key is to
utilize the link's onClick() event handler to call a function that will update the other
frames. It could look like this:
function changeFrames()
{
parent.frames[1].location = 'foo.html'
parent.frames[2].location = 'bar.html'
parent.frames[3].location = 'foobar.html'
}
...
<A HREF="#" onClick="changeFrame()">Change several other frames</A>
Using a HREF="#" causes the location of the frame with the link not to change. However, if
you wanted to load a new page in the current frame also, you could use this:
<A HREF="nextpage.html" onClick="changeFrame()">Change this frame
and others</A>
- Another description submitted by Sunny Hirai:
Suppose you have a frame you use as an index (Frame A), a frame that holds
a banner (Frame B) and a Frame that holds information (Frame C). If you
want to update both frame C and B at the same time, you can add a script
the HTML in Frame C like this:
<SCRIPT>
parent.frames[1].location = 'Banner.html'
</SCRIPT>
where Banner.html is the HTML file you want to load into frame B. Now whenever
you load the HTML with the script in it, Banner.htm will be loaded into the
second frame, in our case, Frame B.
This is how the script works. Parent specifies _parent (in frames parlance). Frames[1]
specifies the SECOND frame specified in _parent (Frames[0] specifies the
first). Location specifies the URL and you can probably figure out the
rest.
I used this because both frames are always updated together. Instead of
writing a function and then linking it in your HTML code (over and over
and over), you can link the second frame to the first frame (you only have
to do it once). This works just like the HTTP-EQUIV="REFRESH".
- And one final description, from Carel Lyn Miske-Ashzryl via the HWG Archive:
<SCRIPT LANGUAGE="JavaScript">
<--
function twoframes()
{
top.frames[n].location="foo.html"
top.frames[n].location="bar.html"
}
</SCRIPT>
// -->
To call this function from HTML:
<A HREF="JavaScript:twoframes()">Click here to change two frames</A>
Change the 'n' in each line to the correct frames array number (look at the
frameset file and count the src files down from the top...starting with 0
instead of one). An onClick="twoframes()" added to the tag will also work
for form buttons, image maps, etc. Also, the script tags 'should' be
between the head tags...
Table of Contents
- How can I support non-frame browsers?
Add a special section for those browsers. After the <FRAME>...</FRAME> section and
before the </HTML> tag, insert:
<NOFRAMES>
Insert content here for non-frame browsers
</NOFRAMES>
Netscape currently requires the <NOFRAMES> section to be within a <FRAMESET> tag.
- Should I use the <BODY> tag inside the <NOFRAMES> tag?
My opinion is probably. Browsers that support Frames are supposed to ignore anything
between the NOFRAME tags and browsers that don't support <NOFRAMES> may
require the <BODY> tag. The only reason you'd need a
BODY tag is if you wanted to include some of the body-specific attributes,
like a background color, for the non-frames capable browser.
However, I have heard it has been reported that some browsers break when
<BODY> is implemented within a <NOFRAMES> tag set, so it may be
best for universal access to avoid it, even if it seems bad style to do
so. (Anyone who can confirm which browsers/version exactly is encouraged to
email me.)
Because Frames were an extension to HTML introduced by Netscape (and later
picked up by Microsoft and AOL) but never precisely defined in a DTD (see the
next question), they can't be guaranteed to work with all browsers.
See also Duif Calvin's email on the subject in the HWG archives at:
http://sunsite.unc.edu/hwg-bin/msgid?199701192152.QAA27656@mule1.mindspring.com&browsing=Aan1bxohmLK
- How do I validate my frames documents?
You can't. Netscape hasn't release a DTD for frames and no-one else has yet reverse-engineered one.
The best you can do is validate the document with an HTML 3.2 or Netscape (Mozilla) DTD. You'll
get 1 error for each frames tag you have in the document. This allows you to validate all other
aspects of your document; you'll have to check the frames tags manually.
Table of Contents
- How do I clear all the frames when going to a new URL? OR
How do I turn off frames when leaving my site?
Use the TARGET="_top" attribute for the <A HREF.. tag.
- My pages open a new window instead of clearing frames
When using Netscape's built-in window names, it's important to watch capitalization.
"_TOP" and "_top" are regarded as different entities. "_TOP" is seen as a specific
name for a window, so a new window is opened when that reference is used. "_top" is
a built-in reference to the top level of the current window (i.e. the current window
without any frames) so all frames are cleared when it is used. Most of the time, the
non-capitalized version is what is needed.
- How do I set the bg color for a specific frame?
Set it in the <BODY BG="... tag for the content of that frame. For example,
a frameset document contains:
<FRAMESET *,*>
<FRAME SRC="this.html">
...
This.html would contain:
<HTML>
<BODY BGCOLOR="#FFFFFF">
...
Then for the frame containg this.html the background color will be white.
Table of Contents
- How can I print more than one frame in a screen?
Netscape currently doesn't provide a way to print more than one frame. You can
print all frames in a screen by clicking in each one to select it, then
choosing "Print Frame" from the file menu.
A different option is provided by Microsoft Internet Explorer 3.0, which
currently reads all frames in a FRAMESET document, but displays them all
sequentially on the page rather than each in their own frame.
- How do I sub-divide a frame?
Nest your <FRAMESET> tags. For example, to get a document that looks like:
+------------------------------+
| red.html |
| |
+--------------+---------------+
| white.html | black.html |
+--------------+---------------+
you would need two frameset tags, one to divide the screen horizontally and a
second to divide it vertically. The vertical division is a sub-division of
the horizontal one since the vertical one isn't for the full screen. The code
would be:
<FRAMESET ROWS="60%,40%">
<FRAME SRC="red.html"> <!--The top frame-->
<FRAMESET COLS="50%,50%"> <!--The bottom frame, which is subdivided-->
<FRAME SRC="white.html"> <!--The left half of the bottom-->
<FRAME SRC="black.html"> <!--The right half of the bottom-->
</FRAMESET>
</FRAMESET>
The frameset tag can be nested many times (I know at least up to 4 levels works - if you want
more nesting than that you probably need to redesign the whole page).
- How do I use TARGET in a BASE/FORM/AREA tag?
You can use the TARGET="" attribute in any tag intended to send a URL to the browser:
<BASE TARGET="window_name">
This causes all links to target a specific window for their update. You can
override this by specifying a specific target in an individual <A
HREF="" TARGET=""> tag.
<FORM ACTION="url" TARGET="window_name">
The result of this form submission will appear in the targeted window.
<AREA SHAPE="shape"; COORDS="x,y,x,y" HREF="url"; TARGET="window_name">
This will create a client-side imagemap hotspot that will update the targeted window.
- Can I remove frames but keep the current page?
This was originall posed as the following question on hwg-main:
I have a page which has one vertical frame to the left with a series of
buttons for navigation within that particular site. I would like to create a
button that when pushed would be able to make that particular frame with the
navigation buttons "disappear", yet keep whatever page is currently loaded
(whether it is a part of the local site or not) and have it display as one
page with no frames.
In answer, David M. Russell supplied a javascript:
<script>
function NoFrames()
{
top.location.href=OtherFrameName.location.href;
}
</script>
<body>
<form>
<Input Type="button" Name="btnNoFrames" Value="No Frames"
onClick="NoFrames()">
</form>
</body>
Table of Contents
- A Back button within Frames
By Koen Kamphuys via the HWG Mailing List Archives:
In Netscape 2.0 back-in-frame is implemented different from NS 3.0. In NS2 you
can only use the right mouse button. A menu pops up, with the option "back in
frame". In NS 3.0 it is done with the back button. Unfortunately, MS Internet
Exporer does it it's own way, again. For that reason, you see so many framed
sites having the text "click the right mouse button in a frame to navigate";
they now should add "when you use Netscape 2.0".
- Frames without borders
To create borderless frames, in the <FRAMESET...> tag, the following parameters
should be added:
<FRAMESET FRAMESPACING="0" FRAMEBORDER="0" BORDERS="no">
NS Currently recognizes the Frameborder attribute, while the latest version of IE
uses the Borders attribute, so it's best to use both, right now anyway. (1/31/97)
- How do I turn off frames when entering my site?
This question usually occurs because someone sees or hears of another site in which
their pages are referenced, but which doesn't use the "_top" reference, so the author's
pages are crammed into a frame on the first site. The best way to solve this is to get
the author of the pages at fault to add the TARGET="_top" to their URL's (or a <BASE
TARGET="_top"> to the page HEAD section). If that fails there are a couple of solutions.
- For every link off your main page, add TARGET="_top" to your A tags.
<A HREF="http://www.elsewhere.com/" TARGET="_top">.
Be sure to make it lowercase, as _TOP is something different (see above). This will make every link off your first
page load in the full browser window, no frames.
- If you need to make all functional pages in your site load without
frames, add a "splash" page to your site with just one link, to your
first page. Include the TARGET attribute in that tag. Name this new page
the same as your original front page and rename the original page something
else, so outside links will come to the splash page first.
For convenience, you might want to add an immediate auto-forward to
that splash page for folks with newer browsers - they'll just skip right
past that page - folks with older browsers will have to click to
continue. To do this, add in the <HEAD> section:
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=elsewhere.html">
Where 1 is the number of seconds to wait until refreshing the page and
elsewhere.html is the page to go to.
Of course, there's still nothing to keep folks from linking your other pages, but this
is just one of the pitfalls of frames as they're currently implemented. If you really
feel strongly about the issue, write Netscape and Microsoft requesting a solution. (They
might listen, who knows!)
- There's too much space on my framed pages OR
I can't get things aligned right on my framed pages
There are several tags you can employ to get your frames, and framed elements, to the
places you want them. However, it's best to remember that each browser interprets the
page differently, so you'll never have the exact same presentation in all browsers
(especially with frames!). With that said, try the following:
- To eliminate or add space at the edges of your frames, use:
MARGINHEIGHT="n" (use a zero in place of the n for no space)
MARGINWIDTH="n"
- To eliminate the borders (only for newer browsers):
FRAMEBORDERS="0" BORDERS="no"
use both for full coverage. (see above.)
- To eliminate or add space around graphics add the following to your
IMG tags:
HSPACE="0" VSPACE="0"
- If you're using tables, space can be reduced with the following
attributes in the TABLE tag:
CELLSPACING="0" and CELLPADDING="0"
- For Internet Explorer users, you can also add the following
attributes to your BODY tag:
TOPMARGIN="0" and LEFTMARGIN="0"
For specific information on these tags and the browsers that support them,
see http://www.eskimo.com/~bloo/html/intro.htm.
- Questions I haven't yet found answers to
If you know answers to these, please email me. Thanks!
- How can I get the title to change when one frame changes?
One possible answer was submitted by Jason M. Wallin:
This solution may be a little bulky and overly complicated, plus I
haven't tested it yet, but it might work.
If the file "index.html" holds all your FRAMESET tags, and is the loaded
page (the page that determines the title), and the file "FrameOne.html"
is the file that you wish loaded (and the one that you want to change
the title), couldn't you place a JavaScript within "FrameOne.html" that
uses WRITELN to rewrite "index.html" with a new value for the <TITLE>
</TITLE> tags? I think that you'd have to have it rewrite the whole
HTML file (index.html), but I think it should work.
Like I said, I haven't tested this (I really haven't the time at the
moment), but I thought that I'd toss it up for your perusal. Let me
know if you have any success with it (if you try it).
Table of Contents
- For More Information:
home |
www development resources |
member services |
mailing lists
hwg operations |
search |
join hwg |
volunteer |
contacts |
credits
This page maintained by faqs@hwg.org.
Last updated on 29 August 1997.
Copyright © 1997 by the HTML Writers Guild.
Please see our legal statement.
|