The hostname
property sets or gets the host name part of the href
attribute value.
Change the hostname of a specific area in an image-map:
document.getElementById("myArea").host = "www.example.com";
Click the button to change the host name of the href
attribute value for 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" target="_blank" shape="circle" coords="50,50,40" alt="Target" href="https://www.java2s.com:8080/index.html#description"> </map>//from www . j ava 2s . c om <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myArea").host = "www.example.com"; document.getElementById("demo").innerHTML = "The hostname was changed"; } </script> </body> </html>