Anchor username Property - Change the username part of a link: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Anchor username Property - Change the username 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()">change the username part of the link above</button>

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

<script>
function myFunction() {/*w  ww  . j  av  a  2 s. c  om*/
    document.getElementById("myAnchor").username = "newUsername";
    document.getElementById("demo").innerHTML = "The username was changed from 'myUserName' to 'newUsername'.";
}
</script>

</body>
</html>

Related Tutorials