參考鏈接:https://developer.mozilla.org/zh-CN/docs/Web/API/Window/onpopstate
代碼如下:
$(document).ready(function(e) {
? ? ? ? ? ? var counter = 0;
? ? ? ? ? ? if (window.history && window.history.pushState) {
? ? ? ? ? ? window.onpopstate = function () {
? ? ? ? ? ? ? ? ? ? ? ? window.history.pushState('forward', null, '#');
? ? ? ? ? ? ? ? ? ? ? ? window.history.forward(1);
? ? ? ? ? ? ? ? ? ? ? ? alert("不可回退");
? ? ? ? ? ? ? ? ? ? };
? ? ? ? ? ? }
? ? ? ? ? ? window.history.pushState('forward', null, '#'); //在IE中必須得有這兩行
? ? ? ? ? ? window.history.forward(1);
});
如果在瀏覽器執(zhí)行了回退操作肃廓,則會觸發(fā)頁面彈出“不可回退”彈框,當然這里可以進行你所需要的不同的處理诲泌;