Javascript examples for DOM HTML Element:Area
The host property sets or gets the hostname and port part of the href attribute value.
Set the host property with the following value
Value | Description |
---|---|
hostname:port | Sets the hostname and port number of a URL |
A String, representing the domain name or IP address and port number of the URL
The following code shows how to Return the hostname and port number of the URL for a specific area in an image-map:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap"> <map name="myMap"> <area id="myId" target="_blank" shape="circle" coords="125,60,10" alt="Venus" href="venus.htm#description"> </map>//from w w w .j a va2 s . c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var v = document.getElementById("myId").host; document.getElementById("demo").innerHTML = v; } </script> </body> </html>