Javascript examples for DOM HTML Element:Anchor
Anchor hostname Property - Change the hostname of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" target="_blank" href="http://www.example.com:443/test.htm#part2">Example link</a></p> <button onclick="myFunction()">change the hostname of the link above</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j a v a 2 s .c om document.getElementById("myAnchor").host = "www.somenewexamplepage.com"; document.getElementById("demo").innerHTML = "The hostname of the Example link was changed."; } </script> </body> </html>