Results 1 to 5 of 5

Thread: Programming a Back button

  1. #1
    Join Date
    Jan 2008
    Posts
    40
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Programming a Back button

    Is there simple syntax available to program a "back" button, or is this a complex matter?

    Kind regards,

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Something like this:

    Code:
    <input type="button" value="Back" onclick="history.go(-1);">
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Not in HTML. But yes, as thetestingsite says, it is pretty simple in javascript, but there are limitations. You cannot get any information about the history, and there are no guarantees that there will be a history to go to, and it requires javascript enabled - those without javascript enabled will get nothing from a button of that sort.

    For the vast majority of occasions, this is something best left to the browser - it has a back button right on it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You could also make it disabled if you haven't had any history yet in that session. Right?
    Jeremy | jfein.net

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Nile View Post
    You could also make it disabled if you haven't had any history yet in that session. Right?
    Not really, you can ask for:

    history.length

    But the precision (+-1) varies with browsers, and once established includes both forward and backward history, so if you were at the start page, with nowhere back to go, but had made 26 forward moves before using back to get back to that page, the length would still be 26, even though there was nowhere back to go.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •