JavaScript--location.href的跳转

页面重载

  true 强制从服务器加载
  false 优先从缓存加载
  window.location.reload(true);



window.location.href、self.location.href、location.href是本页面跳转 parent.location.href 是上一层页面跳转 top.location.href 是最外层的页面跳转
        window.history.forward()    前进
        window.history.back()       后退
        window.history.go(1)        前进
        window.history.go(-1)       后退

window.location.href = "http://www.baidu.com";
window.location.assign(
"http://www.baidu.com");
window.location.replace(
"http://www.baidu.com");

window.location.assign(url) : 加载URL 指定的新的 HTML 文档。就相当于一个链接,跳转到指定的url,当前页面会转为新页面内容,可以点击后退返回上一个页面。

window.location.replace(url) : 通过加载 URL 指定的文档来替换当前文档 ,这个方法是替换当前窗口页面,前后两个页面共用一个

窗口,所以是没有后退返回上一页的

 

 

posted @ 2017-12-24 15:17  QinXiao.Shou  阅读(6968)  评论(0编辑  收藏  举报