Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Browser Back Button

Browser Back Button

Scheduled Pinned Locked Moved JavaScript
javascript
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tiger146
    wrote on last edited by
    #1

    Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

    K S T A V 6 Replies Last reply
    0
    • T tiger146

      Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      Please clarify what it is you want to happen. Is clicking the back button resulting in a page you don't want, or do you want to make the browser go back from javascript? Or do you want something else perhaps? It might be better to try and describe what it is you want to happen.

      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
      -Or-
      A Dead ringer for Kate Winslett[^]

      T 1 Reply Last reply
      0
      • T tiger146

        Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

        S Offline
        S Offline
        Sandeep Mewara
        wrote on last edited by
        #3

        Your question is not clear. Generally, on using browser back button page is reloaded from cache. If you want to handle this behaviour, following tip would help: Browser back button issue after logout[^]

        Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Latest Article(s)]: How to extend a WPF Textbox to Custom Picker Server side Delimiters in ASP.NET

        1 Reply Last reply
        0
        • K Keith Barrow

          Please clarify what it is you want to happen. Is clicking the back button resulting in a page you don't want, or do you want to make the browser go back from javascript? Or do you want something else perhaps? It might be better to try and describe what it is you want to happen.

          Sort of a cross between Lawrence of Arabia and Dilbert.[^]
          -Or-
          A Dead ringer for Kate Winslett[^]

          T Offline
          T Offline
          tiger146
          wrote on last edited by
          #4

          i want if i click the browser back button the current page is reloded ..please help me that one using javascript

          K 1 Reply Last reply
          0
          • T tiger146

            i want if i click the browser back button the current page is reloded ..please help me that one using javascript

            K Offline
            K Offline
            Keith Barrow
            wrote on last edited by
            #5

            Why do you want to do this? I'm not trying to be difficult - stopping the browser back button (which is what you are trying to do in effect) isn't 100% reliable, for example the client might have JavaScript disabled. What you are doing works against the browser's functionality and you are trying to stop a user doing what they want on their own machine. See http://forums.asp.net/t/989339.aspx[^] for a discussion and this[^] (which is quite old). IMO it is more likely you should be handling this on the server and displaying something appropriate, even if it is just a message saying you can't go back.

            Sort of a cross between Lawrence of Arabia and Dilbert.[^]
            -Or-
            A Dead ringer for Kate Winslett[^]

            1 Reply Last reply
            0
            • T tiger146

              Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

              T Offline
              T Offline
              twseitex
              wrote on last edited by
              #6

              history Object Internet Explorer --------------------------------- Contains information about the URLs visited by the client. Attributes/Properties Show: Attributes/Properties Methods Method Description back Loads a previous URL from the History list. forward Loads the next URL from the History list. go Loads a URL from the History list. Property Description length Retrieves the number of elements in the History list. For security reasons, the history object does not expose the actual URLs in the browser history. It does allow navigation through the browser history by exposing the back, forward, and go methods. A particular document in the browser history can be identified as an index relative to the current page. For example, specifying -1 as a parameter for the go method is the equivalent of clicking the Back button. back Method Internet Development Index -------------------------------------------------------------------------------- Loads a previous URL from the History list. Syntax history.back( [iDistance]) Parameters iDistance Optional. Integer that specifies the number of URLs to go back. If no value is provided, the previous URL is loaded. Return Value No return value. Remarks This method performs the same action as a user clicking the Back button in the browser. The back method works the same as history.go(-1). An error does not occur if the user tries to go beyond the beginning of the history. Instead, the user remains at the current page. Standards Information There is no public standard that applies to this method. forward Method Internet Development Index -------------------------------------------------------------------------------- Loads the next URL from the History list. Syntax history.forward() Return Value No return value. Remarks This method performs the same action as when a user clicks the Forward button in the browser. Calling the forward method works the same as calling the go method with a parameter of 1. An error does not occur if the user tries to go beyond the end of the history. Instead, the user remains at the current page. go Method Internet Development Index -------------------------------------------------------------------------------- Loads a URL from the History list. Syntax history.go(vLocation) Parameters vLocation Required. Variant that specifies an integer or a string. An integer indicates the relative position of a URL

              1 Reply Last reply
              0
              • T tiger146

                Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

                A Offline
                A Offline
                Anjum Rizwi 0
                wrote on last edited by
                #7

                function SetStateForNtimes(n) {
                var popState = "?tabid=" + querySt("tabid");
                for (i = 0; i <= n; i++) {
                History.pushState({ state: 2, rand: Math.random() }, "RailEurope", popState);
                }
                }

                function querySt(ji) {
                hu = window.location.search.substring(1);
                gy = hu.split("&");
                for (i = 0; i < gy.length; i++) {
                ft = gy[i].split("=");
                if (ft[0] == ji) {
                return ft[1];
                }
                }
                }

                Click here for more detail (History.js) I have used somthing like above. It works like facebook has implemented. Called this on ready state. window.setTimeout("SetStateForNtimes(20)",2000);

                Hope It will help. Thank You, Anjum Rizwi

                1 Reply Last reply
                0
                • T tiger146

                  Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

                  V Offline
                  V Offline
                  vinodkumarnie
                  wrote on last edited by
                  #8

                  Reloaded for which one..? Clarify your Question...

                  Vinod Kumar B C Software Engineer

                  1 Reply Last reply
                  0
                  • T tiger146

                    Hi when i login into my application when i click the browser back button the page is reloded for that one Please give me the code in javascript

                    D Offline
                    D Offline
                    Deepak Kr1
                    wrote on last edited by
                    #9

                    Use history.back(0); this should give you what you want...

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups