Javascript DOM HTML Area origin Property get

Introduction

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

This property is read-only.

Return the protocol, hostname and port number of the URL for a specific area in an image-map:

var x = document.getElementById("myArea").origin;

Click the button to display the origin part of the href attribute for the myArea area in the image-map.

View in separate window

<!DOCTYPE html>
<html>
<body>

<img src="image1.png" width="100" height="100" usemap="#myFlagMap">

<map name="myFlagMap">
  <area id="myArea" 
        shape="circle" 
        coords="50,50,40" 
        alt="Target" 
        href="https://www.java2s.com">
</map>//from w  w  w .  j a  v  a 2  s . co m

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

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

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

</body>
</html>



PreviousNext

Related