window.location 对象可用于获取当前页面地址(URL)并把浏览器重定向到新页面。
window.location.href 返回当前页面的 href (URL)
用做跳转的话使用windwos.localtion.href();一个路径,意思时从当前页面跳转到新的路径
window.location.replace
跳转的话也可以用windos.location.replace(); 这个也是从当前页面跳转到新的路径
区别:假如有三个页面one two three ,one->two->three
two ---three使用href跳转的话回退回去的是two页面
two ---three使用replace跳转的话回退退回的是one 页面
- window.location.hostname 返回 web 主机的域名
- window.location.pathname 返回当前页面的路径或文件名
- window.location.protocol 返回使用的 web 协议(http: 或 https:)
- window.location.assign 加载新文档yong