iframeタグに name="" を追加すると、そのインラインフレームに対してフレーム名を付けることができます。
<iframe src="example.html" name="test"> 〜 </iframe>
| name="" | 任意のフレーム名を指定します |
|---|
※フレーム名には、アルファベットで始まる半角英数字(一部の記号も使用可)で好きな名前を指定できます。
※フレーム名に使用できる記号は、ハイフン( - )、アンダーバー( _ )、コロン( : )、ピリオド( . )の4つです。
このフレーム名は、リンクにtarget属性を指定する場合や、formの送信でtarget属性を指定する場合に使用されます。
上下に2つのインラインフレームを作り、上のフレームには top 、下のフレームには bottom というフレーム名を付けています。リンクボタンにはそれぞれ target="" を追加して、表示先のフレーム名を top または bottom に指定しています。
<p>
<a href="iexample_a.html" target="top">上のフレームにサンプル1を表示</a>
<br>
<a href="iexample_b.html" target="top">上のフレームにサンプル2を表示</a>
<br>
<a href="iexample_c.html" target="top">上のフレームにサンプル3を表示</a>
</p>
<p>
<a href="iexample_a.html" target="bottom">下のフレームにサンプル1を表示</a>
<br>
<a href="iexample_b.html" target="bottom">下のフレームにサンプル2を表示</a>
<br>
<a href="iexample_c.html" target="bottom">下のフレームにサンプル3を表示</a>
</p>
<p><iframe src="iexample_a.html" width="300" height="80" name="top">サンプル</iframe></p>
<p><iframe src="iexample_a.html" width="300" height="80" name="bottom">サンプル</iframe></p>
▼これをブラウザで見ると次のように表示されます