保存用
window.location.pathname
设置或获取对象指定的文件名或路径。
例:http://localhost:8080/demo/index?uid=119
输出:/demo/index
window.location.href
设置或获取整个 URL 为字符串。
例:http://localhost:8080/demo/index?uid=119
输出:http://localhost:8080/demo/index?uid=119
window.location.port
设置或获取与 URL 关联的端口号码。
例:http://localhost:8080/demo/index?uid=119
输出:8080
window.location.protocol
设置或获取 URL 的协议部分。
例:http://localhost:8080/demo/index?uid=119
输出:http:
window.location.hash
设置或获取 href 属性中在井号“#”后面的分段。
这个属性可以在一些单页应用很好的使用
例:http://localhost:8001/#/login
输出:#/login
window.location.host
设置或获取 location 或 URL 的 hostname 和 port 号码。
例:http://localhost8080/demo/index?uid=119
输出:localhost:8080
window.location.search
设置或获取 href 属性中跟在问号后面的部分。
例:http://localhost:8080/demo/index?uid=119
输出:?uid=119
属性 | 描述 |
---|---|
hash | 设置或获取 href 属性中在井号“#”后面的分段 |
host | 设置或获取 location 或 URL 的 hostname 和 port 号码 |
hostname | 设置或获取 location 或 URL 的主机名称部分 |
href | 设置或获取整个 URL 为字符串 |
pathname | 设置或获取对象指定的文件名或路径 |
port | 设置或获取与 URL 关联的端口号码 |
protocol | 设置或获取 URL 的协议部分 |
search | 设置或获取 href 属性中跟在问号后面的部分 |