The protocol
property sets or gets the protocol of the href attribute value.
Possible Values:
Return the protocol of a link:
var x = document.getElementById("myAnchor").protocol;
Click the button to return the protocol 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() {/*w ww . ja v a 2 s .c om*/ var x = document.getElementById("myAnchor").protocol; document.getElementById("demo").innerHTML = x; } </script> </body> </html>