Usage of the target attribute of the html tag a

Usage of the target attribute of the html tag a
1: If you use the tag <a> to link to a page, I believe everyone knows the role of the target attribute. It refers to the form in which the linked page is displayed. Commonly used values ​​of target are: _blank (open the linked page in a new pop-up browser window) and _self (open the linked page in the original window). Of course, there are also _top and so on, but since they are not commonly used, I will not introduce them here.
For example: <a href="http://jb51.net" target="_blank">123WORDPRESS.COM </a> means to link to 123WORDPRESS.COM and open it in a new window
2: If you use the tag <a> to trigger an action (after the action is completed, you usually jump to a certain page). This action can be divided into two types here:
(1) Actions that do not submit a form (i.e., actions that do not operate on the form). Relevant scenarios in web development, such as deleting a single record, are not very complicated, and do not require many parameters, all of which are submitted in get mode. At this time, you can specify the display format of the page to be jumped to through the target attribute. The usage here is the same as described in 1.
for example
<a href="http://jb51.net/user/deleteAction.do?id=5" target="_self">Delete Xiao Ming</a> means that after the action is processed, a new page will be opened in this window.
(2) The action of submitting in the form of a form (i.e., the action of submitting the data in the form). Such applications are common in web development, such as user registration, information modification, etc. Of course, some people will say that the data in the form can be submitted directly using <input type="submit"> or <input type="button">. But in some cases, you may prefer to submit in the form of <a href="javascript:your js function name">. If you submit it in the form of a tag <a>, and you want to use the attribute target to control the page to jump to after processing, it will not work. At this time, the target attribute is no longer effective. Instead, you should set it in the target attribute of the form to achieve what you want!
for example:

Copy code
The code is as follows:

function check(){ //Verify that it is not empty
if(form1.username.value=""){
return;
}
form1.submit();
}
<form action="http://china.com/user/addAction.do" target="_blank" name="form1">
<input type="text" name="username" >
</form>
<a href="javascript:check();" target="_self">Submit</a>

Indicates that after the action is processed, a new page is opened in a new window. (Although the target attribute of the tag <a> is set here, it will not take effect; instead, the target attribute of the form will take effect).

<<:  A brief discussion on CSS blocking merging and other effects

>>:  Docker sets up port mapping, but cannot access the solution

Recommend

CSS3 to achieve menu hover effect

Result: html <nav id="nav-1"> <...

How to set up a deployment project under Linux system

1. Modify the firewall settings and open the corr...

Pitfalls and solutions for upgrading MySQL 5.7.23 in CentOS 7

Preface Recently, I found a pitfall in upgrading ...

Background image cache under IE6

CSS background image flickering bug in IE6 (backg...

How to change $ to # in Linux

In this system, the # sign represents the root us...

Detailed example of how to implement transaction commit and rollback in mysql

Recently, we need to perform a scheduled migratio...

Detailed steps to configure MySQL remote connection under Alibaba Cloud

Preface As we all know, by default, the MySQL ins...

vue $set implements assignment of values ​​to array collection objects

Vue $set array collection object assignment In th...

Vue implements mobile phone verification code login

This article shares the specific code of Vue to i...

Docker-compose installation yml file configuration method

Table of contents 1. Offline installation 2. Onli...

How to open a page in an iframe

Solution: Just set the link's target attribute...

Pure CSS3 mind map style example

Mind Map He probably looks like this: Most of the...

WEB standard web page structure

Whether it is the background image or the text siz...