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

Javascript examples for DOM HTML Element:Anchor

Description

Anchor protocol Property - Change the protocol of a link:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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


<button onclick="myFunction()">change the protocol part of the link above</button>

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

<script>
function myFunction() {/*from   www  .j av a 2s .co m*/
    document.getElementById("myAnchor").protocol = "mailto:";
    document.getElementById("demo").innerHTML = "The protocol was changed from 'http://' to 'mailto://'.";
}
</script>

</body>
</html>

Related Tutorials