Disable back button in Browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • me2tech
    New Member
    • Feb 2007
    • 14

    Disable back button in Browser

    Please let me know how to disable back button in Browser
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    you cannot do that ... and it would be very annoying, because that button has its purpose ... but you may use the onbeforeunload-event of the current document to call some javascript that you want to have performed when leaving the page ...

    kind regards

    Comment

    • deepakunny
      New Member
      • Sep 2007
      • 1

      #3
      Originally posted by me2tech
      Please let me know how to disable back button in Browser
      disable back button in Browser....

      Pls try this code inside Javascript function

      [CODE=javascript]document.onkeyd own = BackBtnCancel;
      function BackBtnCancel()
      {
      var e = event.srcElemen t.tagName;

      if(event.keyCod e == 8 && e != "INPUT" && e != "TEXTAREA" )
      {
      event.cancelBub ble = true;
      event.returnVal ue = false;
      }
      }[/CODE]

      It really works....
      Last edited by gits; Sep 21 '07, 01:19 PM. Reason: added code tags

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        i assume this disables the key event ... but not the back-button in the toolbar?

        Comment

        • mrhoo
          Contributor
          • Jun 2006
          • 428

          #5
          deepakunny's function disables the backspace key, not the browser back button, and it will throw an error if the browser is not IE.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            Originally posted by mrhoo
            deepakunny's function disables the backspace key, not the browser back button, and it will throw an error if the browser is not IE.
            yep ... this has to be adapted for cross-browser-capability and doesn't solve the original problem ... but it would help to avoid an accidently 'back - action' ...

            kind regards

            Comment

            • me2tech
              New Member
              • Feb 2007
              • 14

              #7
              one more solution you can hav is to keep the inter-blank page and redirect as it loads this page..

              Comment

              Working...