auto-redirect to previous page?

Discussion in 'JavaScript' started by GSto, Jul 20, 2008.

  1. #1
    I was wondering if someone could help me out. I don't know much about javascript, but I'm just looking for a pretty simple/common function. I want something like when you log on here, it takes you to a certain page, then sends you back to previous page automatically. how do I do this?
     
    GSto, Jul 20, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    It not possible using JavaScript alone.

    The form which you use to submit your username and password contains a hidden field whose value is set to the URL of the page on which you filled the form. When you submit the form, the URL is also send. If the login is successful, you get redirected back to the URL which was sent with the form.
     
    rohan_shenoy, Jul 20, 2008 IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sleeping Troll, Jul 21, 2008 IP
  4. GSto

    GSto Peon

    Messages:
    218
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the link, Sleeping Troll.
    So will history.go(-1) do it automatically, or is there something else I need to add?
     
    GSto, Jul 21, 2008 IP
  5. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    that would take them back but not as if they were logged in. Also you will need to go 2 pages back, not 1.
     
    rohan_shenoy, Jul 21, 2008 IP
  6. GSto

    GSto Peon

    Messages:
    218
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'm confused. if I put this after the script runs, why would it not act as if they were logged in, as a cookie would be put in place? secondly, why go back 2 pages instead of 1?
     
    GSto, Jul 24, 2008 IP
  7. GSto

    GSto Peon

    Messages:
    218
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ok, I just tried it the way I said it, and it does log them in, but they have to refresh to see the difference. how can I fix that?
     
    GSto, Jul 24, 2008 IP