A reader writes:
“I have been reading your “Creating Cool Web Pages (HTML 4), and I just
understood how to make frames. However, I am having trouble with my links
opening in the same frame.For example, I have my links in my smaller frame, but all the pages
connected to the links keep on opening in the same smaller frame. How do I
change it so I can have them open in a new window, or open in the bigger
frame?
This is probably the most common challenge people face when they begin to work in a frames-based environment, and the trick to getting this working has two parts: First, you must name each target pane of your frames-based design when you specify it, and Second, you need to use that exact same name as a target attribute with all links you want to point there.
For example, here’s a common approach that you might use to specify a frames-based layout. Notice in particular the words in bold:
<frameset cols="100,*">
<frame src="navbar.html" name="navbar" />
<frame src="welcome.html" name="main" />
</frameset>
You should recognize this as a two-column layout, where the left column is going to start out with the page “navbar.html” while the right column, the main section of the frame, is going to be “welcome.html” to start.
With me so far?
To have the links in the file “navbar.html” actually affect the content of the other pane of the frames-based design, they must reference the name of the pane as specified in the frame statement: name=”main”. Here’s how that would look:
<a href="http://www.intuitive.com/">Intuitive Systems</a>
Right? No! It’s not correct, because I forgot the all-important target attribute. It’s easy to do.
Here’s the correct version of the link:
<a href="http://www.intuitive.com/" target="main">Intuitive Systems</a>
See the difference? It’s not too hard once you remember that you need to specify a target if it’s other than the existing pane.
Even better, you can also specify something like:
<base target="main" />
which means that all links on this particular page are now pointing to the other pane. You override this, if needed, with an explicit target=”_self”.
I hope that clears everything up!
Hi Dave,
Thank you for your clear concise instruction.
I was trying to figure out how to display the contents of a google search in a frame. I read one of your resonses to a Web designer who wanted to prevent people from displaying his content in their frames and understood why I would not be able to do it.
Thanks.
ck