/*-----監聽返回事件-----*/ 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); }
具體調用方法:三個參數,html
1. returnUrl 返回地址url
2. currentUrl 當前頁面地址spa
3. currentTitle 當前頁面titlecode
你要返回的地址,htm
pushHistory("chooseTictik.html","sureOrderTwo.html","確認訂單");