HTML frames targeting frames Free Web Design Tutorials
Home   HTML CSS JavaScript PHP MySQL Usability Glossary
HTMLBasicsCreating a DocumentHead and Body ElementsFormatting TextCreating ListsEmbedding ImagesURLs ExplainedLinking to DocumentsCreating TablesForms - BasicsInput and TextareaSelect ListsFramesetsThe Frame ElementNested FramesetsHTML Frames - Targeting FramesTargetting FramesInline Frames

Home > HTML > Frames - Targeting Framesprinter version

HTML Frames - Targeting Frames

When a link is clicked within an HTML frame to load another document, then by default the document will load into the same frame as the link.

To load a document into a frame, other than the frame containing the link, requires the target attribute to be used within the <a> element in conjunction with the name attribute within the <frame> element.

The name attribute works in the same way with frames as it does with windows since frames are actually treated as windows within HTML.

If we take a 2 column frameset where the left frame contains a link to load a document into the right frame then the frameset will look like that below.

A Two Column Frameset Example
<frameset cols="25%,75%">
    <frame src="left_column.htm">
    <frame src="opening_page.htm" name="right_column">
</frameset>



If we wish a document called "page_2.htm" to load into the right hand frame from a link within the left hand frame then the link within "left_column.htm" will take the form below.

<a href="page_2.htm" target="right_column">Load Page 2</a>


The target attribute can also be used with the <form> element to send the contents of the form to a script then output the results to another frame as shown below.

A Form Targeting Another Frame
<form action="myform.php" method="post" target="right_column">
    <!-- Form Elements -->
    <input type="submit" name="Send">
</form>


If it's required that all returned pages be loaded into a particular frame then the <base> can be used within the <head> element thus.

Using the Base Element for Targeting
<head>
    <base target="right_column">
</head>


Target Values

The <target> attribute can take on a number of special values.



Care must be taken when linking to external websites since in most cases it's undesirable to have a page from an external website displayed inside one of your frames.

To avoid this, within all links to external websites, use the target="_blank" attribute, to load the document into a new window, or the target="_top" attribute, to load the document into the existing browser window.

Previous - Frames nested framesets Previous - Nested Framesets     Next - Frames - Inline Frames Next - Frames inline frames


Privacy | Terms | Contact | Links | Sitemap | RSS Feeds RSS and JavaScript Feeds
©2009 www.webdesignworkmate.co.uk all rights reserved 
Design and Production by smallbizonline website design © 2000-2009
Valid HTML 4.01! Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0Valid CSS!
Recommended Reading
html_and_xhtml

html and xhtml complete reference

learning web design beginners guide