The formtarget
attribute on a submit <button> tag specifies where to display the form response following submission.
The formtarget
attribute requires that the <button> is of type submit.
A formtarget
attribute on the second submit <button> tag.
This button opens a new tab when submitting.
<form action="/tutorial/action.html" target="_self">
<input type="text" name="name" placeholder="Enter your name">
<button type="submit">Submit</button>
<button type="submit" formtarget="_blank">Submit in new tab</button>
</form>
The formtarget
attribute on the button overrides the form's target attribute.
This attribute specifies where to display the response when data is submitted.
Note: The formtarget
attribute only works for submit type buttons.
<button type="submit" formtarget="_blank | _self | _parent | _top | framename">
Value | Description |
---|---|
_self | Opens the page in the same tab/window. This is the default. |
_blank | Opens the page in a new tab. |
_parent | Opens the page in the parent iframe. In the same iframe if there is no parent. |
_top | Opens the page in the topmost part of the iframe. In the same iframe if there is no topmost. |
framename | Opens the page in a named iframe. |
Here is when formtarget
support started for each browser:
Chrome
|
9.0 | Sep 2011 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
10.0 | Sep 2012 |
Opera
|
10.6 | Jul 2010 |
Safari
|
5.1 | Sep 2013 |
Back to <button>