Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

History back() Method go back twice

Using this sample code as an example: Go Back

<script>
function goBack() {
    window.history.back();
}
</script>

Then, pressing this button will be the same as pressing the back button once on the browser.

However I would like to have a button that makes the back button pressed twice. I tried window.history.back(-2); but it doesnt work. also tried window.history.go(-2); but it doesnt give desired results. I could have the button link back to the page but the reason why i want it to go back instead is so that previously entered data in a form is preserved.

like image 894
aderry Avatar asked Jul 06 '17 12:07

aderry


1 Answers

Now

window.history.go(-2);

works; strange.

like image 112
aderry Avatar answered Oct 12 '22 23:10

aderry