Window location.host attribute
- Previous Page Hash
- Next Page Hostname
- Go Up One Level Window Location
Definition and usage
location.host
Attribute to return the host (IP address or domain name) and port of the URL.
You can also set location.host
Attribute, navigate to the same URL using a new host and port.
Tip:If the port 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 host attribute:
location.host
Set host attribute:
location.host = host:port
Attribute value
Value | Description |
---|---|
host:port | The host and port of the URL. |
Return value
Type | Description |
---|---|
String | The host (IP address or domain name) and port of the URL. |
Browser Support
All Browsers Support location.host
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page Hash
- Next Page Hostname
- Go Up One Level Window Location