Javascript examples for DOM HTML Element:Area
The username property sets or gets the username part of the href attribute value.
For Example: https://myUserName:password123@www.example.com, myUserName is the username and password123 is the password.
Set the username property with the following Values
Value | Description |
---|---|
username | Sets the username part of a URL |
A String, representing the username part of the URL
The following code shows how to Return the username part of the URL for a specific area in an image-map:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap"> <map name="myMap"> <area id="myId" shape="circle" coords="125,60,10" alt="Venus" href="https://myUserName:password123@www.example.com"> </map>//from ww w. j a v a2s . co m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myId").username; document.getElementById("demo").innerHTML = x; } </script> </body> </html>