Change the protocol of a link:
document.getElementById("myAnchor").protocol = "mailto:";
Click the button to change the protocol part of the link.
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" href="http://www.java2s.com/">Example link</a></p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w. j av a 2s .com document.getElementById("myAnchor").protocol = "mailto:"; document.getElementById("demo").innerHTML = "The protocol was changed."; } </script> </body> </html>