Is it possible to tell window.location.href
to go back 2 pages in history and reload the page that is called?
i only managed to get it to work like this:
<script type="text/javascript">
window.location.href = "http://www.google.com/";
</script>
Everything else i try with the command history.back(-2)
does not work in my case.
location. reload() reloads the current page with POST data, while window. location. href='your url' does not include the POST data.
The window.location.href property returns the URL of the current page.
The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to be updated.
Using window. location. href it's not possible to send a POST request. What you have to do is to set up a form tag with data fields in it, set the action attribute of the form to the URL and the method attribute to POST, then call the submit method on the form tag.
Try this, it will take you two step back
history.go(-2);
eg,
<a href="www.mypage.com" onclick="javascript:history.go(-2)"> Link </a>
You should use history.back(2);
, not history.back(-2);
.
you can use function history.go(-2) to move backward two pages previously and history.go(2) to move forward 2 page that you left after you back from 2 pages before
<script>
function goBack() {
window.history.go(-2);
}
</script>
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