window.location 说明
属性 | 说明 |
---|
protocol | 协议 |
hostname | 域名 |
port | 端口号 |
host | 域名 + 端口号 |
origin | 协议 + 域名 + 端口号 |
href | 整个url |
pathname | 当前页面的路径名 |
hash | #”后面的部分 |
search | ? 后面的部分 |
| |
方法 | |
assign | 加载新的文档 |
reload | |
replace | |
toString | |
示例
location:{
ancestorOrigins: DOMStringList {length: 0}
hash: ""
host: "127.0.0.1:5500"
hostname: "127.0.0.1"
href: "http://127.0.0.1:5500/3-%20%E7%BB%84%E4%BB%B6%E5%88%B6%E4%BD%9C/index.html"
origin: "http://127.0.0.1:5500"
pathname: "/3-%20%E7%BB%84%E4%BB%B6%E5%88%B6%E4%BD%9C/index.html"
port: "5500"
protocol: "http:"
search: ""
assign: ƒ assign()
reload: ƒ reload()
replace: ƒ replace()
toString: ƒ toString()
valueOf: ƒ valueOf()
}