在H5中,有时并不想让用户返回,虽然违背用户意愿,对用户造成不好的体验,但有时候没办法~
亲测可用哦~
history.pushState(null, null, document.URL);
window.addEventListener("popstate", function () {
history.pushState(null, null, document.URL);
});
//注意:使用此代码生效的前提是需要触发DOM。(简单来说就是点击一下页面)
在H5中,有时并不想让用户返回,虽然违背用户意愿,对用户造成不好的体验,但有时候没办法~
亲测可用哦~
history.pushState(null, null, document.URL);
window.addEventListener("popstate", function () {
history.pushState(null, null, document.URL);
});
//注意:使用此代码生效的前提是需要触发DOM。(简单来说就是点击一下页面)