How to determine the prior page (i.e. page the back button will go to)

Discussion in 'Javascript' started by Rich, Jan 24, 2004.

  1. Rich

    Rich Guest

    Am just beginning to use javascript.

    I have some pages that can be arrived at from more than one other
    page. Yes, the user can use the back button but I'd like to have a
    back link at the bottom of the page.

    Thought there would be a url in referrer but it seem to be empty.
    Rich, Jan 24, 2004
    #1
    1. Advertising

  2. Rich

    Maarten Guest

    <a href="javascript:history.back();">Previous Page</a>
    Maarten, Jan 24, 2004
    #2
    1. Advertising

  3. Rich

    Maarten Guest

    Sorry, acts at once in html. Simply replace ... with < before and with >
    after line.

    ....a href="javascript:history.back();">Back to index</a...
    Maarten, Jan 24, 2004
    #3
  4. Rich <> wrote in message news:<>...
    > Am just beginning to use javascript.
    >
    > I have some pages that can be arrived at from more than one other
    > page. Yes, the user can use the back button but I'd like to have a
    > back link at the bottom of the page.
    >
    > Thought there would be a url in referrer but it seem to be empty.


    If you get an answer send me a notification. I have the same problem.
    C.Panteliadis, Jan 24, 2004
    #4
  5. On Sat, 24 Jan 2004 08:40:20 GMT, Maarten <> wrote:

    > <a href="javascript:history.back();">Previous Page</a>


    Don't use the JavaScript pseudo-protocol when you don't need to. Consider
    what will happen when JavaScript is disabled.

    To the OP:

    Creating your own "Back" link that doesn't go to a fixed location can be a
    bad idea. For a couple of reasons:

    - If the user has JavaScript disabled, your link will do absolutely
    nothing and frustrate the user.
    - If the user goes directly to the page (from their history, or a
    bookmark), going "back" is meaningless and it makes your site unnavigable.
    I come across this frequently, and it's very annoying.

    If the user wants to go back through their history, let them use the
    appropriate button. However, if you insist on creating your own link, use:

    <a href="anActualPage.html" onclick="window.history.back(); return
    false">Back</a>

    You'll have to choose a sensible location for "anActualPage.html", which
    should be a common root for all of the possible referring pages (like the
    main site page). Note that this solution will still leave the second
    problem above unresolved. Only a fixed address, with no JavaScript
    interrupting the link, can solve it.

    Mike

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
    Michael Winter, Jan 24, 2004
    #5
  6. Rich

    Randy Webb Guest

    Re: How to determine the prior page (i.e. page the back button willgo to)

    Maarten wrote:

    > Sorry, acts at once in html. Simply replace ... with < before and with >
    > after line.
    >
    > ....a href="javascript:history.back();">Back to index</a...


    Please read the FAQ:
    http://www.jibbering.com/faq/
    All of it.
    With special attention to Sections 2.3 and 4.24

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/
    Randy Webb, Jan 24, 2004
    #6
  7. Rich

    Peter Guest

    See history object, his property and methods.
    In addition to prev responses, i can add that you can specify how many
    steps to move back/forward i.e. history.go(-3) and even to build menus
    with visited links if you wish.

    http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/history.html

    Peter



    Rich <> wrote in message news:<>...
    > Am just beginning to use javascript.
    >
    > I have some pages that can be arrived at from more than one other
    > page. Yes, the user can use the back button but I'd like to have a
    > back link at the bottom of the page.
    >
    > Thought there would be a url in referrer but it seem to be empty.
    Peter, Jan 24, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Heckart
    Replies:
    6
    Views:
    535
    Rob Heckart
    Nov 26, 2003
  2. sylvia sil
    Replies:
    1
    Views:
    600
    Curt_C [MVP]
    Dec 29, 2004
  3. H. Williams
    Replies:
    1
    Views:
    400
    Steve C. Orr [MVP, MCSD]
    May 6, 2005
  4. Author
    Replies:
    6
    Views:
    3,071
    George
    Jan 22, 2009
  5. Useful Info

    Firefox back button takes me back 2 pages.

    Useful Info, Jun 3, 2007, in forum: Javascript
    Replies:
    0
    Views:
    333
    Useful Info
    Jun 3, 2007
Loading...

Share This Page