[SOLVED] Is there any way to override back button?


I want to override back button in browser so that, for example, if a user came from A.aspx to B.aspx, when he tries to go back from B.aspx it should go to Home.aspx not A.aspx.

Is there any way to accomplish that? It doesn’t matter if it’s using ASP, C#, JavaScript or jQuery.


You could use JQuery to catch the browser back (popstate) event.

$(document).ready(function () {
  if (window.history && window.history.pushState) {
    window.history.pushState('forward', null, null);
    $(window).on('popstate', function () {
      window.location.href = 'http://stackoverflow.com';

Answered By – Moe

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *