How does one go back with JavaScript - Programmers Heaven

Howdy, Stranger!

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

Categories

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.