Anchor port attribute
Definition and usage
port
Attribute set or return href attribute value The port part.
Note:If the port number is not specified in the URL (or if it is the default port of the protocol - for example 80 or 443), some browsers will display 0 or not display.
See also:
JavaScript Reference Manual:location.port attribute
Example
Example 1
Return the port number of the link:
var x = document.getElementById("myAnchor").port;
Example 2
Change the port number of the link:
document.getElementById("myAnchor").port = "80";
Syntax
Return the port attribute:
anchorObject.port
Set port attribute:
anchorObject.port = number
Attribute value
Value | Description |
---|---|
number | Specifies the port number of the URL. |
Technical details
Return value: | String value, representing the port number of the URL. |
---|
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |