Disable browser's back button

后端 未结 20 1443
猫巷女王i
猫巷女王i 2020-11-22 04:27

How to disable browser\'s BACK Button (across browsers)?

相关标签:
20条回答
  • 2020-11-22 05:23

    Even I faced the same situation before...and didn't have any help. try these things maybe these will work for you

    in login page <head> tag:

    <script type="text/javascript">
        window.history.forward();
    </script>
    

    in Logout Button I did this:

    protected void Btn_Logout_Click(object sender, EventArgs e)      
    {
        connObj.Close();
        Session.Abandon();
        Session.RemoveAll();
        Session.Clear();
        HttpContext.Current.Session.Abandon();
    }
    

    and on login page I have put the focus on Username textbox like this:

    protected void Page_Load(object sender, EventArgs e)
    {
        _txtUsername.Focus();
    }
    

    hope this helps... :) someone plz teach me how to edit this page...

    0 讨论(0)
  • 2020-11-22 05:23
    <script>
        $(document).ready(function() {
            function disableBack() { window.history.forward() }
    
            window.onload = disableBack();
            window.onpageshow = function(evt) { if (evt.persisted) disableBack() }
        });
    </script>
    
    0 讨论(0)
提交回复
热议问题