Return the port number of a link:
The result of x could be:
The port property sets or returns the port part of the href attribute value.
Note: If the port number is not specified in the URL (or if it is the scheme's default port - like 80, or 443), some browsers will display 0 or nothing.
The port property is supported in all major browsers.
Return the port property:
Set the port property:
Value | Description |
---|---|
number | Specifies the port number of a URL |
Return Value: | A String, representing the port number of the URL |
---|
Change the port number of a link:
JavaScript reference: location.port Property