Website: Step back on page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    Website: Step back on page

    I'm looking for a java script that when you click on a button it will step you back on web page.
    ie if you're on storefront_1.ht m and you goto storefront_2 and there is a button called "Close" and when you click on it it will take you back to the previous webpage.

    nomad
    not http://storefront_1.ht m
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The browser already has a back button. There's no need for a back button link. Do you want to know some disadvantages? Read this.

    Why not just link to the first page instead like this:
    [HTML]<input type="button" value="Close" onclick="locati on.href='store_ front1.htm'">[/HTML] or you could use a link.

    Comment

    • nomad
      Recognized Expert Contributor
      • Mar 2007
      • 664

      #3
      Originally posted by acoder
      The browser already has a back button. There's no need for a back button link. Do you want to know some disadvantages? Read this.

      Why not just link to the first page instead like this:
      [HTML]<input type="button" value="Close" onclick="locati on.href='store_ front1.htm'">[/HTML] or you could use a link.
      I know how to do that one, what I'm looking for is it should take you back to the previous page no matter what what the second page is.
      ie it has to do with -1

      nomad

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        Originally posted by nomad
        I know how to do that one, what I'm looking for is it should take you back to the previous page no matter what what the second page is.
        ie it has to do with -1

        nomad
        the qouted link from acoder showed the window.history-object already ... that you may use but should not use ;) ... i agree with that opinions ... you normally shouldn't have to use the history-back-method ... since the browser has a control for it already ... but sometimes i think you need such an option for whatever reason that might be ... so i think the history-object is what you are looking for? here is a short overview:

        window.history-object

        kind regards

        Comment

        • nomad
          Recognized Expert Contributor
          • Mar 2007
          • 664

          #5
          Originally posted by gits
          the qouted link from acoder showed the window.history-object already ... that you may use but should not use ;) ... i agree with that opinions ... you normally shouldn't have to use the history-back-method ... since the browser has a control for it already ... but sometimes i think you need such an option for whatever reason that might be ... so i think the history-object is what you are looking for? here is a short overview:

          window.history-object

          kind regards
          Thanks for the info that is what I was looking for.

          Need this because I have an a small web page that has info only but no menu on it.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by nomad
            Thanks for the info that is what I was looking for.

            Need this because I have an a small web page that has info only but no menu on it.
            Is it a popup window with no toolbar?

            Comment

            • nomad
              Recognized Expert Contributor
              • Mar 2007
              • 664

              #7
              Originally posted by acoder
              Is it a popup window with no toolbar?
              its not ready a pop-up window considering most people avoid them, its just a small window that opens and gives addition info. want the user to click on it to close it.

              nomad
              PS Found out how to do it

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by nomad
                PS Found out how to do it
                Yes, history.back() or history.go(-1) will send you back one page.

                I can see one place where it can make sense to use it. That would be when you have a restricted access page which you can only get to if you click on submit or something from the first page. If you try to access it directly, it redirects you back to the first page. Since you know for certain what Back would take you to, none of the disadvantages apply.

                Comment

                Working...