Image useMapプロパティ
Image オブジェクト
定義と用法
useMap プロパティは、画像の usemap 属性の値を設定または取得します。
usemap 属性は、クライアントサイドイメージマップ(クリック可能な領域を持つ画像マップ)を指定します。
usemap 属性は map 要素の name 属性と関連します。この2つにより、画像とマップ間の関連付けを作成できます。
構文
imageObject.useMap=value
useMap プロパティは次の値を指定できます:
| 值 | 説明 |
|---|---|
| #mapname | ハッシュ文字("#")に map 要素の名前を加えたもの |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが useMap プロパティをサポートしています。
例
例
クライアントサイドイメージマップの usemap 属性値を返します:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
</head>
<body>
<img id="planets" src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="The planet Venus" href="venus.htm.html">
</map>
<p>usemap属性の値:
<script>
document.write(document.getElementById("planets").useMap);
</script>
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
</head>
<body>
<img id="planets" src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="The planet Venus" href="venus.htm.html">
</map>
<p>usemap属性の値:
<script>
document.write(document.getElementById("planets").useMap);
</script>
</p>
</body>
</html>
試してみる »
Image オブジェクトその他の拡張