Javascript DOM HTML Area username Property get

Introduction

The username property sets or gets the user name of the href attribute value.

Return the username part of the URL for a specific area in an image-map:

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

Click the button to display the user name 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://userName:password123@www.example.com">
</map>//  ww w. j a va 2  s.co  m
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

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

</body>
</html>



PreviousNext

Related