The shape
property sets or gets the shape attribute of an area.
It specifies the shape of an area in the image map.
The shape attribute works together with the coords
attribute to specify the size, shape, and placement of an area.
Property Values are listed as follows:
Value | Description |
---|---|
default | Specifies the entire region |
rect | Defines a rectangular region |
circle | Defines a circular region |
poly | Defines a polygonal region |
Get the shape of a specific area in an image-map:
var x = document.getElementById("myArea").shape;
Click the button to return the shape of the myArea
area in the image-map.
<!DOCTYPE html> <html> <body> <img src="image1.png" width="100" height="100" usemap="#myFlagMap"> <map name="myFlagMap"> <area id="myArea" shape="circle" coords="50,50,40" alt="Target" href="https://www.java2s.com"> </map>/* w w w. ja v a2 s . c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myArea").shape; document.getElementById("demo").innerHTML = x; } </script> </body> </html>