disabling browser back button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikramkumar
    New Member
    • Mar 2008
    • 4

    disabling browser back button

    Hi all,
    This is Vikram kumar.
    In my application i want to disable browser back and forward button using
    javascript.
    Please help me,
    Thanks.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    in case you really need this 'annoying' override of well known and useful browser-behaviour you may play around with something like this

    kind regards

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      You can't really disable the back button, but you can use onbeforeunload to warn the user that they will lose important information if not saved (in a web application).

      The link only provides tricks. You can also use location.replac e to prevent entries in the history.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        Originally posted by acoder
        You can't really disable the back button, but you can use onbeforeunload to warn the user that they will lose important information if not saved (in a web application).

        The link only provides tricks. You can also use location.replac e to prevent entries in the history.
        yup ... that is true ... :) the best way would just be to not avoid or workaround 'browser-provided' functionalities but to integrate them in the application ... since the browser is the platform for the application and thus it builds the 'application framework' for the webapp ... it is a bit a philosophical question and my personal point of view is that what i said :) ... even though there are some useful statements from a user-interface-design view that states that we shouldn't avoid or suppress the standards-behaviour of applications that a user always uses and has learned to use it a way that a application allows him to ... so as an example it would be a bad design if the user clicks the back-button of the browser where he expects to get to the page before ... but instead the 'embedded' application sends him to a page he never wanted to visit ... and much worser ... now he wants to go back and the forward button has a new assigned behaviour and he will not know how to get to the page where his journey began :) ...

        kind regards

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Good points especially about the browser being the platform for the application.

          In fact, in Ajaxy applications, developers want to return the back button functionality to the application since it's so useful. Very rarely do you need to disable the back button. Usually all that is needed is to prevent the page being cached and user authentication so that the user cannot view previous pages when logged out and good use of onbeforeunload (where supported) to prevent loss of unsaved data.

          This question has been asked a number of times, so Frinavale has begun a soon-to-be article here.

          Comment

          Working...