Latest web development tutorials
 

Input Submit formTarget Property

< Input Submit Object

Example

Find out where the response will be displayed after submitting a form:

var x = document.getElementById("mySubmit").formTarget;

The result of x could be:

_blank // the response is displayed in a new window/tab
Try it Yourself »

Definition and Usage

The formTarget property sets or returns the value of the formtarget attribute of a submit button.

The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.

The formtarget attribute overrides the target attribute of the <form> element.

Note: The formtarget attribute is new for the <input> element with type="submit" in HTML5.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The formTarget property is supported in all major browsers.

Note: The formTarget property is not supported in Internet Explorer 9 and earlier versions.


Syntax

Return the formTarget property:

submitObject.formTarget

Set the formTarget property:

submitObject.formTarget="_blank|_self|_parent|_top|framename"

Property Values

Value Description
_blank The response is displayed in a new window/tab
_self The response is displayed in the same frame (this is default)
_parent The response is displayed in the parent frame
_top The response is displayed in the full body of the window
framename The response is displayed in a named iframe

Technical Details

Return Value: A String, representing where to display the response after submitting the form

More Examples

Example

Change the value of the formtarget attribute of a submit button:

document.getElementById("mySubmit").formTarget = "_self";
Try it Yourself »

Related Pages

HTML reference: HTML <input> formtarget attribute


< Input Submit Object