location.assign()、location.href、location.replace(url)的不同

 

 

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

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2022-01-19
猜你喜欢
  • 2021-12-14
  • 2021-10-12
  • 2022-12-23
  • 2021-10-08
  • 2022-03-07
相关资源
相似解决方案