Disabling back button is not working in firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kashhere
    New Member
    • Feb 2008
    • 21

    Disabling back button is not working in firefox

    Hi all

    i am working on a site
    in which user need to be in same page
    when the user clicks on back button

    Its working in IE, Chrome but not in firefox
    in firefox when i click on the back button though i have embedded the script
    its not working
    can anyone please let me know the solution

    here i am forwarding the script function for back button functionality
    which i have called using body onload


    JAVA SCRIPT FUNCTION :-
    -----------------------------------------

    Code:
    
    function DisablingBackFunctionality()
    {
    var URL;
    var i ;
    var QryStrValue;
    URL=window.location.href ;
    i=URL.indexOf("?");
    QryStrValue=URL.substring(i+1);
    if (QryStrValue!='X')
    {
    window.location=URL + "?X";
    }
    }

    Thanks in advance
    waiting for your valuable reply
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The first question to ask yourself is why you're trying to disable the back button. Rarely is it a good idea. Is it to prevent logged out users from seeing cached content, or to prevent loss of data in a web application, or what?

    Comment

    • kashhere
      New Member
      • Feb 2008
      • 21

      #3
      Originally posted by acoder
      The first question to ask yourself is why you're trying to disable the back button. Rarely is it a good idea. Is it to prevent logged out users from seeing cached content, or to prevent loss of data in a web application, or what?

      Actually i dont want to show the users the previous page
      after logged out
      show i need to disable the back button
      could u please guide me towards the solution

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        In that case, prevent caching on the previous page, so when someone is logged out and goes back, they see the login page instead of the page they were at.

        Comment

        • kashhere
          New Member
          • Feb 2008
          • 21

          #5
          I have tried

          with

          Code:
          window.history.forward(-1);
          bt its working in firefox fine
          but its not working perfectly in Chrome.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            That's a bit of a hack. What if someone has JavaScript disabled?

            Disable caching in your server-side script/code.

            Comment

            • kashhere
              New Member
              • Feb 2008
              • 21

              #7
              thanks fr ur replies

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                You're welcome. So did you get it working?

                Comment

                Working...