The port
property sets or gets the port of the href attribute value.
Return the port number of a link:
var x = document.getElementById("myAnchor").port;
Click the button to display the port number of the link.
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" href="http://www.java2s.com:80">Example link</a></p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* ww w . ja va 2s.co m*/ var x = document.getElementById("myAnchor").port; document.getElementById("demo").innerHTML = x; } </script> </body> </html>