when i hit back button in browser it should navigate to desired location,
but the code written below works for all the buttons including the 'form' buttons
window.onbeforeunload = function () {
location.replace('http://www.google.com');
return "Th开发者_StackOverflow社区is session is expired and the history altered.";
}
how i can restrict this functionalty to browsers back button alone
thanks
Tampering with history is not allowed in the browsers due to privacy & security reasons. Due to this, you won't be able to do this.
精彩评论