Javascript Reference - HTML DOM Area origin Property








The origin property returns the protocol, hostname and port number of the href attribute value.

Browser Support

origin Yes Yes Yes Yes Yes

Syntax

areaObject.origin

Return Value

A String representing the protocol, the domain name and port number of the URL.





Example

The following code shows how to get the protocol, hostname and port number of the URL for a specific area in an image-map.


<!DOCTYPE html>
<html>
<body>
<!--from w w  w  .java  2  s  . c  om-->
<img src="http://java2s.com/style/demo/border.png" width="145" 
     height="126" usemap="#myImageMap">

<map name="myImageMap">
  <area id="myArea" shape="circle" coords="124,58,8" alt="myImage" href="http://example.com">
</map>

<p id="demo"></p>

<button onclick="myFunction()">test</button>

<script>
function myFunction() {
    var x = document.getElementById("myArea").origin;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: