Setting a "back" link to user/browser's back

Discussion in 'Web Design and Development' started by Sdashiki, Mar 21, 2007.

  1. Sdashiki macrumors 68040

    Sdashiki

    Joined:
    Aug 11, 2005
    Location:
    Behind the lens
    #1
    I need a "back" link.

    but not one that I specifically specify, one that is based off the actual "back button" history of their browser.

    for instance, a single page can be linked from multiple other pages, and it would be silly to have a back button go back to some arbitrary choice of mine instead of the actual page they came from to get here.

    is this possible with simple CSS/HTML or am I in JS territory?

    as always, i try googling for answers but keywords here, elude me.
     
  2. Sdashiki thread starter macrumors 68040

    Sdashiki

    Joined:
    Aug 11, 2005
    Location:
    Behind the lens
    #3
    JS only.

    figures, but thanks it works!

    is there anyway to make it be simple text and not a button though?
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    I believe this'll do the trick:
    Code:
    <a href="javascript:history.back()">Back</a>
     
  4. Sdashiki thread starter macrumors 68040

    Sdashiki

    Joined:
    Aug 11, 2005
    Location:
    Behind the lens
  5. Yvan256 macrumors 601

    Yvan256

    Joined:
    Jul 5, 2004
    Location:
    Canada
    #6
    Not recommended

    If people want to browse to where they came from, they should use their browser's back button. That's what it's there for.

    If I search for content in a search engine, then load your page (let's say page 31) and want to go back a page (page 30 of your content), the back link should do exactly that.

    Using javascript for links will also break navigation for people with Javascript disabled (and that was about 5-10% last time I checked), and will also break indexing of your website (a lot, if not most, search engines can't follow javascript links).

    Your content should have some structure, so your back button should send the user to the "parent page", such as going from "iPod shuffle" to "iPods". You know your content structure, so it's up to you to decide where that "back" link should go to.
     

Share This Page