Javascript examples for DOM HTML Element:Anchor
The protocol property sets or gets the protocol part of the href attribute value.
Value | Description |
---|---|
protocol | Sets the protocol of a URL: file: ftp: http: https: mailto: etc.. |
A String, representing the protocol part of the URL
The following code shows how to Return the protocol of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" href="http://www.example.com/test.htm#part2">Example link</a></p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . j ava 2s . co m*/ var v = document.getElementById("myAnchor").protocol; document.getElementById("demo").innerHTML = v; } </script> </body> </html>