Javascript Reference - HTML DOM Image isMap Property








The isMap property sets or gets whether an image should be part of a server-side image-map.

Browser Support

isMap Yes Yes Yes Yes Yes

Syntax

Return the isMap property.

var v = imageObject.isMap

Set the isMap property.

imageObject.isMap=true|false

Property Values

Value Description
true|false
  • true - The image will be part of a server-side image-map
  • false -The image will NOT be part of a server-side image-map




Return Value

A Boolean type value, true if the image is part of a server-side image-map, otherwise it returns false.

Example

The following code shows how to Set the isMap property.


<!DOCTYPE html>
<html>
<body>
<a href="demo_form.asp">
<img id="myImg" src="http://java2s.com/style/demo/border.png" alt="test" width="100" height="100">
</a><!--from   w ww  .j a v  a 2s.  c  o  m-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myImg").isMap = true;
    document.getElementById("demo").innerHTML = "set";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to check if an image is part of a server-side image-map.


<!DOCTYPE html>
<html>
<body>
<a href="demo_form.asp">
  <img id="myImg" src="http://java2s.com/style/demo/border.png" alt="test" width="100" height="100" ismap>
</a><!--from   ww w . j av  a2 s .c om-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myImg").isMap;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

The code above is rendered as follows: