尝试了以下代码,但没有破坏Popstate Event。
请帮助我们提供一个示例,其中我可以Popstate Event根据条件销毁该示例。
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
if (true){
history.pushState(null, document.title, location.href);
console.log('Back Button Prevented');
} else {
window.removeEventListener('popstate', ()=> {
console.log('Go back');
}, true);
history.back();
}
});
缥缈止盈
眼眸繁星
相关分类