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
If you tap and hold the back button in Chrome Android, the option will list out the recently closed history of the website pages that you've visited in the session. This allows you to jump back to any older page without navigating to the subsequent back page.
The history. back() method loads the previous URL (page) in the history list. The history. back() method only works if a previous page exists.
Can't we just go back to page one and start all over again?” “The only reason for being a bee is to make honey. And the only reason for making honey is so I can eat it.”
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.
Try this:
$previous = "javascript:history.go(-1)"; if(isset($_SERVER['HTTP_REFERER'])) { $previous = $_SERVER['HTTP_REFERER']; }
in html:
<a href="<?= $previous ?>">Back</a>
The JavaScript code is initialize as fallback for HTTP_REFERER
variable sometimes not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With