Javascript DOM HTML Anchor password Property get

Introduction

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

Return the password part of a link:

var x = document.getElementById("myAnchor").password;

Click the button to display the password part of the link.

View in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

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

</body>
</html>



PreviousNext

Related