0
点赞
收藏
分享

微信扫一扫

禁止html页面返回上一层

两种方式:

// 方式一  触发返回上一层页面事件,只会重新加载当前页面
window.addEventListener('pageshow', function(e) {
if (e.persisted) {
location.reload();
}
})

// 方式二 不会出现刷新效果
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function(e) {
history.pushState(null, null, document.URL);
})

// 两种方式可以同时使用

 



举报

相关推荐

0 条评论