Target attribute usage of html Tag a _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
I believe that web developers will all use tags, either for links or to trigger an action. Here I want to talk about the usage of the attribute target. 1: If tags are used to link to a page, the role of the target attribute is well known. It refers to the display of the linked page in the form of common values of target: _ blank (open the linked page in a new browser window), _ self (open the linked page in the original window ). Of course, there are also _ top and so on. Because it is not commonly used, we will not introduce it here.
For example, the home indicates you want to link to the home and open it in a new window.
2: If a tag is used to trigger an action (usually jump to a page after the action is completed ). This action can be divided into two types:
(1) do not submit an action in the form Format (that is, do not perform an action on the form ). For scenarios related to web development, such as deleting a single record, such operations are not very complex and many parameters are required. They are submitted in get mode. You can use the target attribute to specify the display form of the page to jump. The usage here is the same as described in 1.
For example
Deleting James indicates that after the action is processed, a new page is displayed in this window.
(2) actions submitted in the form (that is, actions to submit data in the form ). In web development, such applications are commonly used with user registration and information modification. Of course, some people will say that the data in the form can be directly used Or . But in some cases, you may be more willing to submit in the form. If you submit it in the form of tags, and you want to use the attribute target to control the page to jump after processing is complete, it will not work. At this time, the target attribute no longer works. Instead, you should specify it in the target attribute of form so that it will be as expected!
For example:

The Code is as follows:


Function check () {// verification is not empty
If (form1.username. value = ""){
Return;
}
Form1.submit ();
}

Submit


After the action is processed, a new page is displayed in the new window. (Although the target attribute of the tag is set here, it does not take effect, but the target attribute of form takes effect ).

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.