<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" target="_blank" href="../../www.example.com:80/test.htm#part2">Example link</a></p>

<p>Click the button to change the pathname of the link above.</p>

<p><b>Tip:</b> Open the link and look in the address bar before and after you have clicked the "Try it" button, to see the effect.</p>

<button onclick="myFunction()">Try it</button>

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

<script>
function myFunction() {
    document.getElementById("myAnchor").pathname = "newpathname";
    document.getElementById("demo").innerHTML = "The pathname was changed from 'test' to 'newpathname'";
}
</script>

</body>
</html>