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

Javascript examples for DOM HTML Element:Anchor

Description

Anchor hostname Property - Change the hostname of a link:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials