Change the password part of a link:
document.getElementById("myAnchor").password = "newPassword101";
Click the button to change the password part of the link.
<!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() {/* ww w. ja v a2 s.c o m*/ document.getElementById("myAnchor").password = "password888"; document.getElementById("demo").innerHTML = "The password was changed."; } </script> </body> </html>