For example, if you have two windows, one named
table_of_contents and the other
mainwin, you might have HTML like the following in
the table_of_contents window:
<a href="chapter01.html" target="mainwin">
Chapter 1, Introduction
</a>
The browser loads the specified URL when the user clicks on this
hyperlink, but instead of displaying the URL in the same window as
the link, it displays it in the window named
mainwin. If there is no window with the name
mainwin, clicking the link creates a new window
with that name and loads the specified URL into it.
The target and name attributes
are part of HTML and operate without the intervention of JavaScript,
but there are also JavaScript-related reasons to give names to your
frames. We've seen that every Window object has a
frames[] array that contains references to each of
its frames. This array contains all the frames in a window (or
frame), whether or not they have names. If a frame is given a name,
however, a reference to that frame is also stored in a new property
of the parent Window object. The name of that new property is the
same as the name of the frame. Therefore, you might create a frame
with HTML like this:
<frame name="table_of_contents" src="toc.html">