Use window.location.href to go 2 pages back and reload

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>

Tags:

Javascript