1、从商品列表进入到详情页
window.location.href=detail.html
2、在详情页购买,未登录状态跳转到登录
window.location.href=login.html
登录成功之后返回
此时点击回退按钮,回到了登录页面
history.back() //回到了login.html
请问如何回到列表页面?
如果是页面内容中模拟 history.back()还有希望控制,如果是直接在浏览器程序上点后退就比较麻烦了,只能借助login页面以及cookie等等判断来重新定位跳转了(但逻辑上很麻烦,效果不怎么好——你只能定义一种逻辑不在登录后不停留在login页面,要么前向,要么后向)
history.back()
那如果是这样呢?登录之后history.back()这样的话,上次就是list了。
list window.location.href= list -> info window.location.href= list -> info -> login history.back() list -> info
登陆成功之后的返回,应该使用history.back()