jquery go back to previous page
php go back to previous page after submit
php back to previous page without refresh
return to previous page
Is there a function I can attach as a click event of a button to make the browser go back to previous page?
<input name="action" type="submit" value="Cancel"/>
Add this in your input element:
<input action="action" onclick="window.history.go(-1); return false;" type="submit" value="Cancel" />
Put this to the button
onclick handle. It should look like this:
<input name="action" onclick="history.back()" type="submit" value="Cancel"/>
For Going to previous page
<a href="##" onClick="history.go(-1); return false;">Go back</a>
if we want to more than one step back then increase
For going 2 steps back history.go(-2) For going 3 steps back history.go(-3) For going 4 steps back history.go(-4) and so on.......
<input name="action" type="submit" value="Cancel" onclick="window.history.back();"/>
You just need to call the following:
- This doesn't work in all browsers for me, I had to do the following
<input action="action" type="button" value="Back" onclick="window.history.go(-1); return false;" />This answer is quite old, so it could have been an issue introduced into more modern versions of browsers. :)
- Does this show the previous page from cache or reloads the previous page from the server?
- What's the
action="action"part for? And is it valid html??
- Put this to the button onClick handle
- You could be more clear like giving the answer in the code
- What's the browser support on that?
- Works fine, but oftentimes if user decides to change language on specific page with the button like this, the back button to previous page will turn the language back, instead of page...