アンカーターゲットプロパティ
例
リンクのターゲットを「_blank」に変更します(リンクは新しいウィンドウで開きます)。
document.getElementById("myAnchor").target = "_blank";
定義と使用法
targetプロパティは、リンクのtarget属性の値を設定または返します。
target属性は、リンクされたドキュメントを開く場所を指定します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
target | Yes | Yes | Yes | Yes | Yes |
構文
ターゲットプロパティを返します。
anchorObject.target
ターゲットプロパティを設定します。
anchorObject.target = "_blank|_self|_parent|_top|framename"
プロパティ値
Value | Description |
---|---|
_blank | Opens the linked document in a new window |
_self | Opens the linked document in the same frame as it was clicked (this is default) |
_parent | Opens the linked document in the parent frameset |
_top | Opens the linked document in the full body of the window |
framename | Opens the linked document in a named frame |
技術的な詳細
戻り値: | リンクされたドキュメントを開く場所を表す文字列 |
---|
その他の例
例
リンクのターゲット属性の値を返します。
var x =
document.getElementById("myAnchor").target;
関連ページ
HTMLリファレンス:HTML <a>ターゲット属性
❮アンカーオブジェクト