Free tech support / small logo


How do I get links to work on a frames-based design?

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.

Dave's Answer:

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!









Subscribe!
Never miss another Q&A article! Click to subscribe: Add to Google Reader Add to My Yahoo! Subscribe in NewsGator RDF XML
Comments

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

Posted by: Chaviva Kaufman at January 9, 2012 12:56 AM

I have something to say, now that you mention it, but ...
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Recent Entries


Search
I Need Help!
Need Help? Ask Dave Taylor!


© 2002 - 2012 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.