window.location.href,window.location.replace(),window.location.reload() 三者的区别
window.location.href、window.location.replace() 和 window.location.reload() 都与页面地址和跳转相关,但作用不同。window.location.href="url" 只是改变 URL 地址;
window.location.replace("url") 会将地址替换成新 URL,该方法通过指定 URL 替换当前缓存在客户端历史里的项目,因此使用 replace 之后不能再通过"前进"和"后退"访问已被替换的 URL,这一特点对于做一些过渡页面非常有用;
window.location.reload() 则是强制刷新页面,从服务器重新请求。简单说,href 是普通跳转并保留历史记录,replace 是替换历史记录的跳转,reload 是重新加载当前页面。