SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Nov 2000
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript back hyperlink

    Hi, could someone tell me what script I need to allow me to make a link go Back to the previous page? I remember seeing it somewhere and think it has to do with the favorites. Thanks in advance

  2. #2
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onclick="history.back()" and onclick="history.forward()"

    ...should do the trick

    alternatively, to navigate through the history...

    onclick="history.go(-1)" to go back one step or
    onclick="history.go(1)" to go forward one step.

    Of course, you can leap further by using the relevant number in the second method.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  3. #3
    SitePoint Addict
    Join Date
    Nov 2000
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're a star m8, thanks a lot!

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only thing you can't do is go back to a page in the
    history by testing it's name against a regex ( or against
    anything for that matter ) since the only
    way to get at the history names is to go into the registry

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    SitePoint Addict
    Join Date
    Nov 2000
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry I must be really thick on this one!

    I can't get it to work?

    I have typed this <a href="onclick=history.back()">test</a>
    i get to this page from another in the same directory but when I hit the back link I get a paged can't be displayed?

    Do I have to put other code somewhere?

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onclick is a property of the a tag.

    if you want the action in the onclick then put:

    href="javascript: history.back();"

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  7. #7
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="#" onclick="history.back()">test</a>

    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  8. #8
    SitePoint Addict
    Join Date
    Nov 2000
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ha....A little web searching got me the answer!

    <a href="#" onclick="history.back();return false">Go Back To The Previous Page</a> this works a treat


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
  •