简体   繁体   English

禁用浏览器的后退按钮

[英]Disable button back of browser

I tried doing it this way but it takes interaction with the screen for it to work, is there any way to make it work without interaction我试过这样做,但它需要与屏幕交互才能工作,有没有办法让它在没有交互的情况下工作

history.pushState(null, document.title, location.href);
    history.back();
    history.forward();
    window.onpopstate = function () {
        history.go(1);
    };

do you mean disable back button of a browser?你的意思是禁用浏览器的后退按钮?

window.history.pushState(null, null, window.location.href);

window.onpopstate = function () { window.history.go(1); };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM