Javascript DOM HTML Area port Property set

Introduction

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

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

document.getElementById("myArea").port = "443";

Click the button to change the port number 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" 
        target="_blank" 
        shape="circle" 
        coords="50,50,40" 
        alt="Target" 
        href="http://www.example.com:80/test.htm">
</map>//from w ww  . j a  va 2 s  . co  m

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

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

<script>
function myFunction() {
  document.getElementById("myArea").port = "8080";
  document.getElementById("demo").innerHTML = "The port number was changed.";
}
</script>

</body>
</html>



PreviousNext

Related