Area hostnameプロパティ
Area オブジェクト
定義と使い方
hostname プロパティは、href プロパティの値のホスト名部分を設定または返します。
構文
areaObject.hostname=hostname
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは hostname プロパティをサポートしています。
例
例
次の例では、イメージマップ内の "Venus" 領域のホスト名を返します。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
</head>
<body>
<img src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>Venus 領域のホスト名:
<script>
document.write(document.getElementById('venus').hostname);
</script>
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
</head>
<body>
<img src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>Venus 領域のホスト名:
<script>
document.write(document.getElementById('venus').hostname);
</script>
</p>
</body>
</html>
上記の例の出力結果:
Venus 領域のホスト名: www.example.com
試してみる »
Area オブジェクト その他の拡張