Form target attribute
Definition and Usage
target
Sets or returns the value of the target attribute in the form.
The HTML target attribute specifies a name or keyword that indicates where the response received after submitting the form should be displayed.
See also:
HTML Reference Manual:HTML <form> target Attribute
Example
Example 1
Change the location where the received response is displayed after submitting the form (open the response in a new window instead of in the same frame where it is clicked):
document.getElementById("myForm").target = "_blank";
Example 2
Return the value of the target attribute in the form:
var x = document.getElementById("myForm").target;
Syntax
Return the target attribute:
formObject.target
Set the target attribute:
formObject.target = "_blank|_self|_parent|_top|framename"
Attribute value
Value | Description |
---|---|
_blank | Open in a new window. |
_self | Open in the same frame when clicked (default). |
_parent | Open in the parent frame set. |
_top | Open in the entire window. |
framename | Open in named frame. |
Technical Details
Return Value: | A string value indicating where the response received after submitting the form is displayed. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |