Get the name of the image-map that is used with the object:
var x = document.getElementById("myObject").useMap;
The usemap attribute of the object element is only supported in Firefox.
Click the button to display the name of the image-map that is used with the object.
<!DOCTYPE html> <html> <body> <object id="myObject" data="image1.png" width="145" height="126" usemap="#myFlagMap"></object> <map name="myFlagMap"> <area shape="rect" coords="0,0,30,30" alt="Site" href="https://java2s.com"> <area shape="circle" coords="90,58,10" alt="Web" href="https://java2s.com"> <area shape="circle" coords="50,50,40" alt="Target" href="https://www.java2s.com"> </map>//from w ww . ja v a2 s.c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myObject").useMap; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The useMap
property sets or gets the value of the usemap attribute of an <object> element.
The usemap attribute sets the name of an image-map to use with the object.
Value | Description |
---|---|
#mapname | Specifies a hash character ("#") plus the name of the map element to use |
The useMap
property returns a String representing the name of the image-map that is used with the object.