Area pathnameプロパティ
Area オブジェクト
定義と用法
pathname プロパティは、href 属性値のパス名部分を設定または返します。
構文
areaObject.pathname=path
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが pathname プロパティをサポートしています。
ヒントと注記
注意:以下の例では、IE と Opera は "jsref/venus.htm" を返しますが、Firefox、Chrome、Safari は "/jsref/venus.htm" を返します。
例
例
以下の例では、"Venus" エリアの href 属性値のパス名を返します:
<!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>金星エリアのパス:
<script>
document.write(document.getElementById('venus').pathname);
</script>
</p>
<p><b>注意:</b> IEおよびOperaブラウザは "jsref/venus.htm" を返します、
一方Firefox、Chrome、Safariブラウザは "/jsref/venus.htm" を返します。</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>金星エリアのパス:
<script>
document.write(document.getElementById('venus').pathname);
</script>
</p>
<p><b>注意:</b> IEおよびOperaブラウザは "jsref/venus.htm" を返します、
一方Firefox、Chrome、Safariブラウザは "/jsref/venus.htm" を返します。</p>
</body>
</html>
上記の例の出力結果:
金星エリアのパス: /try/demo_source/venus.htm
試してみる »
Area オブジェクト その他の拡張