Javascript examples for DOM HTML Element:Anchor
Anchor host Property - Change the hostname and port number 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 and port number of the link above</button> <p id="demo"></p> <script> function myFunction() {/* w w w . j a v a 2 s .c om*/ document.getElementById("myAnchor").host = "www.somenewexamplepage.com:344"; document.getElementById("demo").innerHTML = "The hostname and port number of the Example link was changed."; } </script> </body> </html>