Window location.port attribute
- Previous Page pathname
- Next Page protocol
- Go to the Previous Level Window Location
Definition and usage
port
Sets or returns the port number of the URL.
Tip:If the port number is not specified in the URL, or it is the default port (80 for http) or (443 for https), most browsers will return an empty string.
See also:
Syntax
Return the port attribute:
location.port
Set the port attribute:
location.port = port
Attribute value
Value | Description |
---|---|
port | The port number of the URL. |
Return value
Type | Description |
---|---|
String |
The port number of the URL. If the port number is not specified or it is the default port (such as 80 or 443), most browsers will return an empty string. |
Browser Support
All Browsers Support location.port
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page pathname
- Next Page protocol
- Go to the Previous Level Window Location