Disable Back Button in Browser using jquery?

后端 未结 8 658
慢半拍i
慢半拍i 2020-12-03 05:55

I would like to Disable Back button when user click on logoff for this i delete only cookies of that user not session in my application. And want to disable Back button

8条回答
  •  执笔经年
    2020-12-03 06:32

    var path = 'Test.aspx'; //write here name of your page 
    history.pushState(null, null, path + window.location.search);
    window.addEventListener('popstate', function (event) {
        history.pushState(null, null, path + window.location.search);
    });
    

    This works across all browsers(except < IE10) even if urls have query strings appended.

    For this you don't even need jquery.

    have a look here to apply this for your page.

提交回复
热议问题