jsのコードでブラウザの[戻る]ボタンを無効に使用します

これはjqueryの最初の導入、jqueryのを使用しています

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
function disableBack() {
    if (window.history && window.history.pushState) {
        $(window).on('popstate', function () {
            window.history.pushState('forward', null, '');
            window.history.forward(1);
        });
    }
    window.history.pushState('forward', null, '');
    window.history.forward(1);
}

ページが初期化されるときは、上記の関数を呼び出すことができます。

おすすめ

転載: www.cnblogs.com/xl5230/p/11572344.html