HTML target and htmltarget

Source: Internet
Author: User

HTML target and htmltarget
Definition and usage

<A> the target attribute of a tag specifies where to open the link document.

If a <a> tag contains a target attribute, the browser loads and displays the documents in the framework or window named by the href attribute of the tag and whose names match the target. If the frame or window with the specified name or id does not exist, the browser opens a new window, marks the window, And loads the new document into the window. From then on, the hyperlink document can point to this new window.

Open new window

The pointed hyperlink makes it easy to create an efficient browser tool. For example, a simple list of content documents can redirect documents to a separate window:

target="view_window">Preface</a></li>  <li><a href="chap1.html" target="view_window">Chapter 1</a></li>  <li><a href="chap2.html" target="view_window">Chapter 2</a></li>  <li><a href="chap3.html" target="view_window">Chapter 3</a></li></ul>

Try it yourself

When you select a link in the content list for the first time, the browser opens a new window, marking it as "view_window", and then displays the content of the document you want to display. If you select another link from the content list and the "view_window" is still open, the browser will load the selected document into that window again to replace the previous documents.

Throughout the process, the window containing the content list is accessible to users. You can click a connection in the window to change the content of the other window.

Open a window in the framework

You do not need to open a complete browser window. The more common way to use target is to direct the hyperlink content to one or more frameworks in a <frameset> display. You can put the content list in one of the frameworks of a document with two frameworks, and use this adjacent framework to display the selected documents:

<frameset cols="100,*">  <frame src="toc.html">  <frame src="pref.html" name="view_frame"></frameset> 

Try it yourself

When the browser first displays the two frameworks, the framework on the left contains the directory, and the framework on the right contains the preface.

This is the source code of "toc.html:

target="view_frame">Preface</a></li>  <li><a href="chap1.html" target="view_frame">Chapter 1</a></li>  <li><a href="chap2.html" target="view_frame">Chapter 2</a></li>  <li><a href="chap3.html" target="view_frame">Chapter 3</a></li></ul>

Note that in the document "toc.html", the target of each link is "view_frame", that is, the framework on the right.

When you select a link from the left-side frame directory, the browser loads the associated document and displays it in the "view_frame" frame on the right. When other links are selected, the content in the framework on the right also changes, while the framework on the left remains unchanged.

Special goals

Four reserved target names are used as special document redirection operations:

_ Blank

The browser always loads the target document in a new and untitled window.

_ Self

The <a> label of this target value is the default target for all unspecified targets, so that the target document is loaded and displayed in the same framework or window as the source document. This goal is redundant and unnecessary unless used together with the target attribute in the document title <base> tag.

_ Parent

This object enables the document to be loaded into the parent window or contains the framework set of the Framework referenced by the hyperlink. If the reference is in a window or in a top-level framework, it is equivalent to the target _ self.

_ Top

This object causes the document to load the window containing this hyperlink. The _ top object will clear all contained frameworks and load the document into the entire browser window.

Tip: all four values of these targets start with an underscore. Any window or target starting with an underscore is ignored by the browser. Therefore, do not use the underscore as the first character of any framework name or id defined in the document.

Syntax
<a target="value">
Attribute Value
Value Description
_ Blank Open the linked document in a new window.
_ Self Default value. Open the linked document in the same framework.
_ Parent Open the linked document in the parent framework set.
_ Top Open the linked document throughout the window.
Framename Open the linked document in the specified framework.

 

 

 

From: http://www.w3school.com.cn/tags/att_a_target.asp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.