Javascript DOM HTML Area username Property set

Introduction

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

Change the username part of a specific area in an image-map:

document.getElementById("myArea").username = "newUsername";

Click the button to change the username 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://userName:password123@www.example.com">
</map>/*from  www .ja  v a  2s.c o  m*/
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("myArea").username = "newUsername";
  document.getElementById("demo").innerHTML = "The username was changed from 'johnsmith' to 'newUsername'.";
}
</script>

</body>
</html>



PreviousNext

Related