Javascript DOM HTML Area port Property get

Introduction

The port property sets or gets the port of the href attribute value.

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

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

Click the button to display the port 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 .  c  o  m

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

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

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

</body>
</html>



PreviousNext

Related