Skip to content
Advertisement

Go Back to Previous Page

I am using a form to “Rate” a page. This form “posts” data to a php script elsewhere. I simply want to display a link after the form is processed which will bring the user back to previous page. Can I do this using javascript in my php script?

GF

Advertisement

Answer

You can use a link to invoke history.go(-1) in Javascript, which is essentially equivalent to clicking the Back button. Ideally, however, it’d be better to just create a link back to the URL from whence the user was posted to the form – that way the proper “flow” of history is preserved and the user doesn’t wonder why they have something to click “Forward” to which is actually just submitting the form again.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement