

#
“formtarget”属性について
“formtarget”属性は“type="submit"”を指定した“button”要素でフォームを送信したときの応答画面の表示方法を指定します。
多くの場合、フォームの応答画面の表示方法は“form”要素の“target”属性で指定されますが、“button”要素に“target”属性を指定した場合はボタンごとに応答画面の表示方法を指定することができます。
“form”要素に“target”属性が指定されている場合は“formtarget”属性の値が優先されます。
#
指定できる値
属性値 | 説明 |
---|---|
_blank | 新しいブラウジング・コンテキストに表示 |
_self | 現在のブラウジング・コンテキストに表示 |
_parent | 現在のブラウジング・コンテキストの1つ上位のブラウジング・コンテキストに表示 |
_top | 現在のブラウジング・コンテキストの最上位のブラウジング・コンテキストに表示 |
ブラウジング・コンテキスト名 | 任意のブラウジング・コンテキストに表示 |
#
サンプルコード
<form action="sample-formtag5.php" method="get">
<fieldset>
<legend>猫を探す</legend>
<p>
<label><input type="radio" name="type" value="品種">品種</label>
<label><input type="radio" name="type" value="色">色</label>
<label><input type="radio" name="type" value="名前">名前</label>
</p>
<p><label>キーワード:<input type="search" name="query"></label></p>
</fieldset>
<p>
<button type="submit" formtarget="_blank">検索結果を新しいウィンドウに表示</button>
<button type="submit" formtarget="_self">検索結果を現在のウィンドウに表示</button>
</p>
</form>