Button formTarget Property
Example
Return where to display the response after submitting a form:
var x = document.getElementById("myBtn").formTarget;
Try it Yourself »
Definition and Usage
The formTarget property sets or returns the value of the formtarget attribute of a button.
The formtarget attribute specifies where to display the response after submitting the form. This attribute overrides the form's target attribute.
The formtarget attribute is only used for buttons with type="submit".
Note: The formtarget attribute is new for the <button> element in HTML5.
Browser Support
Property | |||||
---|---|---|---|---|---|
formTarget | Yes | 10.0 | Yes | Yes | Yes |
Syntax
Return the formTarget property:
buttonObject.formTarget
Set the formTarget property:
buttonObject.formTarget = "_blank|_self|_parent|_top|framename"
Property Values
Value | Description |
---|---|
_blank | Loads the response in a new window/tab |
_self | Loads the response in the same frame (this is default) |
_parent | Loads the response in the parent frame |
_top | Loads the response in the full body of the window |
framename | Loads the response 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 button:
document.getElementById("myBtn").formTarget = "_self";
Try it Yourself »
Example
Another example on returning the formTargert property:
var x = document.getElementById("myBtn").formTarget;
Try it Yourself »
Related Pages
HTML reference: HTML <button> formtarget attribute
❮ Button Object