Javascript examples for DOM HTML Element:Anchor
The origin property returns the protocol, hostname and port number of the href attribute value.
This property is read-only.
A String, representing
The following code shows how to Return the protocol, hostname and port number of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" href="http://www.example.com:8080/test.htm#part2">Example link</a></p> <button onclick="myFunction()">display the origin of the link above</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . ja va2 s . c om*/ var x = document.getElementById("myAnchor").origin; document.getElementById("demo").innerHTML = x; } </script> </body> </html>