The location.host
property returns the host (IP adress or domain) and port of a URL.
The location.host
property can also be set, to navigate to the same URL with a new host and port.
If the port number is not specified in the URL, or if it is a default port (80 for http) or (443 for https), most browsers will return an empty string.
Return the host property:
location.host
Set the host property:
location.host =
host:port
Value | Description |
host:port | The host and port number of the URL. |
Type | Description |
A string | The host (IP address or domain) and port number of a URL. |
location.host
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!