【发布时间】:2021-04-11 23:54:51
【问题描述】:
点击浏览器后退按钮时,如果不点击/触摸页面内的任何地方,导航应该被禁用。
以下实现仅在点击页面内时有效。
history.pushState(null, null, window.location.href);
history.back();
window.onpopstate = () =>{ // not getting activate without clicking inside page
console.warn('DISABLE BROWSER NAVIGATION');
history.forward();
}
【问题讨论】:
标签: javascript