Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How does one go back with JavaScript

dansebdanseb Posts: 10Member
Hi Guys.

How would I write a function that when executed, takes the user back to the previous page of a website?
Can't seem to find it in any of my books.

Many thanks for any help.

Daniel

Comments

  • jaycssjaycss Posts: 8Member
    : Hi Guys.
    :
    : How would I write a function that when executed, takes the user back to the previous page of a website?
    : Can't seem to find it in any of my books.
    :
    : Many thanks for any help.
    :
    : Daniel
    :
    The first one, which does not need a number in the parenthesis, returns the user to the
    previous page (like using the 'Back' button), the command is:
    history.back()

    The second one lets you set how far 'forward' (insert a positive number in the parenthesis)
    or 'back' (insert a negative number in the parenthesis) you want the user to go, the command is:
    history.go

    The third one really isn't javascript (it's HTML) but I thought I would include it.
    It uses a form button and is coded like this:




Sign In or Register to comment.