/*-----监听返回事件-----*/ function pushHistory(returnUrl,currentUrl,currentTitle) { window.addEventListener("popstate", function(e) { window.location.href=returnUrl; }, false); var state = { title: currentTitle, url: currentUrl }; window.history.pushState(state, currentTitle, currentUrl); }
具体调用方法:三个参数,
1. returnUrl 返回地址
2. currentUrl 当前页面地址
3. currentTitle 当前页面title
你要返回的地址,
pushHistory("chooseTictik.html","sureOrderTwo.html","确认订单");
转载地址:https://www.cnblogs.com/xianxianxxx/p/7562023.html
备注:
这种方法亲测可以,但是这种方法我觉得每次回退都会向历史记录中添加一条记录,不知道这样有没有什么影响
本文介绍了一种使用JavaScript监听浏览器回退按钮的方法,并通过修改浏览器的历史记录实现自定义的回退行为。具体实现包括定义监听事件、设置返回地址及当前页面信息等。

5217

被折叠的 条评论
为什么被折叠?



