OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

History back() Method go back twice

  • Thread starter Thread starter aderry
  • Start date Start date
A

aderry

Guest
Using this sample code as an example: Go Back

Code:
<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.

<p>Using this sample code as an example:
Go Back</p>

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

<p>Then, pressing this button will be the same as pressing the back button once on the browser.</p>

<p>However I would like to have a button that makes the back button pressed twice.
I tried <code>window.history.back(-2);</code> but it doesnt work.
also tried <code>window.history.go(-2);</code> 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.</p>
 

Latest posts

I
Replies
0
Views
1
Isaac P. Liu
I
U
Replies
0
Views
1
user3658366
U
G
Replies
0
Views
1
Giampaolo Levorato
G
M
Replies
0
Views
1
Marcelo Rodrigo Nascimento
M
Top