Window location.host 属性
- Previous Page hash
- Next Page hostname
- Go Back to the Previous Level Window Location
定义和用法
location.host
属性返回 URL 的主机(IP 地址或域名)和端口。
还可以设置 location.host
属性,导航到使用新主机和端口的相同 URL。
提示:如果 URL 中没有指定端口号,或者是默认端口(http 为 80)或(https 为 443),大多数浏览器将返回空字符串。
另请参阅:
语法
返回 host 属性:
location.host
设置 host 属性:
location.host = host:port
属性值
值 | 描述 |
---|---|
host:port | URL 的主机和端口号。 |
返回值
类型 | 描述 |
---|---|
字符串 | URL 的主机(IP 地址或域名)和端口号。 |
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 Back to the Previous Level Window Location