How To disable BACK BUTTON?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • romeo971987
    New Member
    • Feb 2008
    • 1

    How To disable BACK BUTTON?

    disable back button..... page should no do postback...
    i used history.go, history.back, session.abandon ...and many more...but still previous page shows.... help me to expire the previous page.......
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    This has been asked a number of times. See, for example, this and this.

    Comment

    • sravan2000
      New Member
      • Feb 2008
      • 1

      #3
      this is the code to disable back button
      just try this

      <script language="javas cript">
      javascript:wind ow.history.forw ard(1);
      </script>

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by sravan2000
        <script language="javas cript">
        javascript:wind ow.history.forw ard(1);
        </script>
        There are a number of problems with this.

        Firstly, language is deprecated - use type="text/javascript" instead.

        Secondly, there's no need for the javascript: protocol here.

        Thirdly, and most importantly, there's no reliable way to disable the back button. One way is to use location.replac e, but it can't be 100% reliable. If this is needed for a web application, just warn the user instead.

        Comment

        Working...