The location.hostname
property returns the host (IP adress or domain) of a URL.
The location.hostname
property can also be set, to navigate to the same URL with a new hostname.
Return the hostname property:
location.hostname
Set the hostname property:
location.hostname =
hostname
Value | Description |
hostname | The hostname of the URL. |
Type | Description |
A string | The host (IP address or domain) of a URL. |
location.hostname
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!