Anchor password Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

The password property sets or gets the password part of the href attribute value.

In the url of https://myUserName:password123@www.example.com, myUserName is the username and password123 is the password.

Property Values

ValueDescription
password Sets the password part of a URL

Return Value

A String, representing the password part of the URL

The following code shows how to Return the password part of a link:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="https://myUserName:password123@www.example.com">Example link</a></p>

<button onclick="myFunction()">Get the password part of the link above</button>

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

<script>
function myFunction() {/*from  w w w  . j  a va  2 s  .co  m*/
    var v = document.getElementById("myAnchor").password;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials