Javascript examples for DOM HTML Element:Anchor
Anchor pathname Property - Change the path name of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" target="_blank" href="http://www.example.com:80/test.htm#part2">Example link</a></p> <button onclick="myFunction()">change the pathname of the link above</button> <p id="demo"></p> <script> function myFunction() {//from w w w. j av a2s. c o m document.getElementById("myAnchor").pathname = "newpathname"; document.getElementById("demo").innerHTML = "The pathname was changed from 'test' to 'newpathname'"; } </script> </body> </html>