Kishore Patra
Kishore Patra

Reputation: 245

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>

Upvotes: 0

Views: 41

Answers (1)

Rohit RC
Rohit RC

Reputation: 469

<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();
}

Upvotes: 1

Related Questions