js阻止浏览器后后退
2020-08-31 本文已影响0人
青灯无味
//阻止后退的所有动作,包括 键盘、鼠标手势等产生的后退动作。
history.pushState(null, null, window.location.href)
window.addEventListener('popstate', function () {
history.pushState(null, null, window.location.href)
})
//阻止后退的所有动作,包括 键盘、鼠标手势等产生的后退动作。
history.pushState(null, null, window.location.href)
window.addEventListener('popstate', function () {
history.pushState(null, null, window.location.href)
})