Image useMapProperty

Image 对象参考手册Image Object

Definition and Usage

The useMap property can set or return the value of the image's usemap attribute.

The usemap attribute specifies a client-side image map for an image (a clickable area image map).

The usemap attribute is related to the name attribute of the map element. Together, they can create an association between the image and the map.

Syntax

imageObject.useMap=value

The useMap property can be one of the following values:

Value Description
#mapname A hash character ("#") plus the name of the map element


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the useMap property.


Example

Example

Return the usemap attribute value of the client-side image map:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (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>The value of the usemap attribute:</p>
<script>
document.write(document.getElementById("planets").useMap);
</script>
</p>

</body>
</html>

Try it yourself »


Image 对象参考手册Image Object Other Extensions