Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

Creating Hyperlinks in Frames

 
Creating hyperlinks in HTML frames is a little more complicated than creating them in standard web pages. The key difference is outlined in the following:
  • In a standard web page, clicking on a hyperlink will —by default— reload the original browser window with the new page.
  • In a framed web page, on the other hand, clicking on a hyperlink will —by default— reload the frame in which the hyperlink is located in with the new page.
Loading the new page in the same frame, however, may only be desirable in certain situations.

In other situations, you may instead require that:
  1. A hyperlink in one frame loads a new page in another frame.

    OR
  2. A hyperlink loads a new page which breaks out of the frame.

In all cases, to make sure hyperlinks in a framed page perform their intended function, you will have to do two things:
  1. Use the name attribute to give each of your frames a special identity.
  2. Use the target attribute in your hyperlinks.
There are also some standard frame target names predefined by the HTML specification which control other possibilities of handling hyperlinks in frames. All of this is detailed below starting with how...


A Link in One Frame Loads a New Page in Another Frame


In the following example, we'll refer to our basic frame layout, (discussed in more detail on the previous page) where we created two framed columns. These two columns are specified by the two <frame> tags in the frameset document.


THE name ATTRIBUTE

The name attribute is used in each <frame> tag to allow you to give that frame a special identity. This identity will serve as a 'target name' which is used in hyperlinks that load new pages intended for that frame.

The value of the name attribute can be anything you want as long as it's unique. In the source code of our frameset document, the menu frame is simply called 'menu' and the content frame is called 'content':

SOURCE CODE - name attributes highlighted

<html>

<head>
<title>HTML Frames - A Basic Frame Layout</title>
</head>

<frameset cols="25%,75%">
<frame src="menu.htm" name="menu">
<frame src="chapter1.htm" name="content">
</frameset>

</html>




THE target ATTRIBUTE

Now that we've given each frame a special identity, let's create hyperlinks in the menu frame that load new pages into the content frame. To do this, we simply use the standard HTML hyperlink code and then insert the target attribute. The value of the target attribute is the name of the frame (in this case "content") into which you wish to load the new web page.

The code of menu.htm, the frame source document of the menu frame, illustrates the use of the target attribute:

SOURCE CODE - menu.htm uses target attributes in hyperlinks

<html>

<head>
<title>Site Menu</title>

</head>

<body>

<center><h3>War of the Worlds</h3>
<b><i>by H. G. Wells</i></b><br>
<br>

<a href="chapter1.htm" target="content">Chapter 1</a><br>
<a href="chapter2.htm" target="content">Chapter 2</a><br>
<a href="chapter3.htm" target="content">Chapter 3</a><br>
<a href="chapter4.htm" target="content">Chapter 4</a><br>

</body>

</html>




DEFINING A DEFAULT TARGET

If the hyperlinks in a particular frame are always intended to load a new page in another frame then there is a shortcut you can use to save yourself having to insert the target attribute in all your links. All you have to do is insert the base element in between the <head>...</head> tags of the frame source document containing the links. The target attribute is then used in the base element to define the default target for any hyperlink on that web page. Thus, in our basic frame layout, the source code of menu.htm could be rewritten as follows:

SOURCE CODE - menu.htm uses base element to define default target

<html>

<head>
<title>Site Menu</title>

<base target="content">

</head>

<body>

<center><h3>War of the Worlds</h3>
<b><i>by H. G. Wells</i></b><br>
<br>

<a href="chapter1.htm">Chapter 1</a><br>
<a href="chapter2.htm">Chapter 2</a><br>
<a href="chapter3.htm">Chapter 3</a><br>
<a href="chapter4.htm">Chapter 4</a><br>

</body>

</html>



In the absence of the base element, all hyperlinks in framed pages should contain the target attribute. This is especially important when creating hyperlinks to web pages that are not on your web site, a.k.a., external links. If you neglect to specify a target in the hyperlink code, the new page will —by default— load into the frame that the hyperlink is located in. This will result in someone else's content displayed in your frame giving the appearance that their content is part of your website. To avoid this —and any legal hassles that may arise as a result of this— you'll need to understand how...


A Link Loads a New Page Which Breaks Out of the Frame


The target="_top" attribute/value pair is used to create a hyperlink that —when activated— loads a new page which breaks out of all framesets. The new page is thus loaded into the original full browser window.

Here's an example of the source code used in this scenario:


<a href="http://example.com/" target="_top">Example.com</a>


(Example.com represents the website you wish to load outside of your frameset and into the full original browser window.)


Recognized Frame Target Names


A set of frame target names are specially reserved by the HTML specification. These target names are recognized by browsers to accomodate a number of different scenarios when creating hyperlinks in frames. They are used as the value of the target attribute in your hyperlink code to perform their respective functions. Note that they are all preceded by the underscore ( _ ) character.

Here's the syntax of the hyperlink code:


<a href="web address" target="frame target name">link text</a>


Their functions are outlined in the table below:


Frame target nameWhat it does
_top Loads the new page into the full original browser window (see above).
_blank Loads the new page into a completely new browser window. (You would thus have two browser windows open: one containing the original framed page and the other containing the new page.)
_self Loads the new page into the same frame in which the hyperlink exists in. (If you don't specify a target in your hyperlink then this is what happens by default.)
_parent Loads the new page into the immediate frameset parent of the frame in which the hyperlink exists in. (Useful in advanced frame layouts.)


*   *   *


Alright then, let's continue on to learn how to tweak those frames so that they don't look so butt ugly...





Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
<~ BACK TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell