Disable Back Button in Browser using jquery?

后端 未结 8 674
慢半拍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:29

    Sunil was correct, but to use jQuery paste the code below into any page that you want to prevent going back too. I tested this in IE 11, chrome and FF, which worked fine.

    $(document).ready(function () {
        function disableBack() {window.history.forward()}
    
        window.onload = disableBack();
        window.onpageshow = function (evt) {if (evt.persisted) disableBack()}
    });
    

提交回复
热议问题