Kishore Patra February 2016

how to implement "back to" functionality using JavaScript for all browser

widndow.history.back() is not working in firefox as in chrome.
In firefox it goes to the previous page and comes back to the current page like back and forth.
But in chrome it is going to the previous page and then that's previous page and so on..
so how can I implement this functionality(as in chrome) in firefox browser..

    <div class="link2Back"><a href="javascript:void(0)" onclick="history.back()" class="col-xs-12">Back to ... </a></div>

Answers


Rohit Chidrewar February 2016

<a href="index.jsp" id="backButton">GO BACK</a>


var backbutton = document.getElementById("backButton");
backbutton.onclick = function(e){
  e = e || window.event; 
  e.preventDefault(); 
  window.history.back();
}

Post Status

Asked in February 2016
Viewed 2,495 times
Voted 5
Answered 1 times

Search




Leave an answer