Form target attribute

Definition and Usage

target Set or return 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 position 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";

Try it yourself

Example 2

Return the value of the target attribute in the form:

var x = document.getElementById("myForm").target;

Try it yourself

Syntax

Return target attribute:

formObject.target

Set 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: 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