HTML <button> formtarget属性
例
2つの送信ボタンがあるフォーム。最初の送信ボタンはデフォルトのターゲット( "_self")でフォームデータを送信し、2番目のボタンはフォームデータを新しいウィンドウ(target = "_ blank")に送信します。
<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname"
name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<button type="submit" >Submit</button>
<button type="submit" formtarget="_blank">Submit to a new window</button>
</form>
定義と使用法
このformtarget
属性は、フォームの送信後に応答を表示する場所を指定します。この属性は、フォームの属性をオーバーライドしtarget
ます。
このformtarget
属性は、が付いたボタンにのみ使用されます
type="submit"
。
ブラウザのサポート
表の数字は、属性を完全にサポートする最初のブラウザーバージョンを示しています。
Attribute | |||||
---|---|---|---|---|---|
formtarget | 9.0 | 10.0 | 4.0 | 5.1 | 10.6 |
構文
<button type="submit" formtarget="_blank|_self|_parent|_top|framename">
属性値
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 |
❮HTML<button>タグ