You are here: Reference > JavaScript > client-side > HTML DOM > properties > useMap (applet, img, object, ...)

useMap property (applet, img, object, ...)

Browser support:
Sets or retrieves the URL to use as an image map.
This property identifies a map element to use as an image map for the object to specify the clickable (anchor-like) regions in the current image.

Syntax:

object.useMap;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: useMap

Possible values:

String that sets or retrieves the URL of the image map.
The URL often contains a bookmark extension (#name), where the 'name' is the value of a map object's name property. The URL can be an absolute or relative path as well. Relative paths are relative to the base URL. The base URL is the location of the current document, but it can be overridden by the base tag.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the useMap attribute:
<img id="myImage" src="area.gif" width="504px" height="126px" border="0px" alt="Solar System" usemap="#SampleMap" />
<map name="SampleMap">
    <area shape="rect" coords="1,-1,83,125" alt="rectangle" href="#" />
    <area shape="circle" coords="234,57,30" alt="circle" href="#" />
    <area shape="poly" coords="363,37,380,40,399,35,420,47,426,63,423,78,430,94,409,90,395,92,379,84,371,67,370,57" alt="polygon" href="#" />
</map>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the useMap property:
<head>
    <script type="text/javascript">
        function GetUseMap () {
            var image = document.getElementById ("myImage");
            alert (image.useMap);
        }
    </script>
</head>
<body>
    <img id="myImage" src="area.gif" width="504px" height="126px" border="0px" alt="Solar System" usemap="#SampleMap" />
    <map name="SampleMap">
        <area shape="rect" coords="1,-1,83,125" alt="rectangle" href="#" />
        <area shape="circle" coords="234,57,30" alt="circle" href="#" />
        <area shape="poly" coords="363,37,380,40,399,35,420,47,426,63,423,78,430,94,409,90,395,92,379,84,371,67,370,57" alt="polygon" href="#" />
    </map>
    <br />

    Get the name of the map element used as a map specified with the useMap property!
    <br />
    <button onclick="GetUseMap ();">
        Get the name of the map used for the image!
    </button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content