Javascript examples for DOM HTML Element:Anchor
The port property sets or gets the port part of the href attribute value.
Value | Description |
---|---|
number | Sets the port number of a URL |
A String, representing the port number of the URL
The following code shows how to Return the port number of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" target="_blank" href="http://www.example.com:443/test.htm#part2">Example link</a></p> <button onclick="myFunction()">Get the port number of the link above</button> <p id="demo"></p> <script> function myFunction() {//from w w w. j av a2s.c o m var v = document.getElementById("myAnchor").port; document.getElementById("demo").innerHTML = v; } </script> </body> </html>