Area hostname Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Area

Description

The hostname property sets or gets the hostname part of the href attribute value.

The href attribute sets the destination of a link in an area.

Set the hostname property:

ValueDescription
hostname Sets the hostname of a URL

Return Value

A String, representing the domain name or IP address of the URL

The following code shows how to Return the hostname of the URL for a specific area in an image-map:

Demo Code

ResultView the demo in separate window

<!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  www.  j  a va  2s . co  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>

Related Tutorials