我试图阻止用户在我的Web应用中返回。为此,我尝试捕获
window.onpopstate
事件并添加e.preventDefault
来取消返回按钮的效果。但看起来没有生效。window.addEventListener('popstate',function(e){
console.log(e); e.preventDefault();
});
阻止浏览器的popstate
事件是不可能的吗?或者是我的做法有问题吗?