What I am trying to achieve is to redirect the user to yahoo's page once he has clicked the browser's back button. Here is my attempt, currently nothing happens:
window.addEventListener('popstate', function() {
var lastVisitedUrl = window.history.go(-1);
window.history.replaceState(lastVisitedUrl , "Sample Title", "/yahoo.com");
window.location.href.back()
});
How can I make the redirection once the browser back button is clicked?