Browser back button going to Prev page after logout

I have logout button in my angularjs(1.8) application. On click of it calling the login page url. After logout, when i click the browser back button again it is going to my application page instead of login page.

<input type="button" id="btnLogout" value="Logout" name="btnLogout" style="background-color:crimson;color:white;font-weight:bold" ng-click="interfaceControllerVm.Logout()" />


angular.module("main")
    .controller("interfaceController", InterfaceController);

function InterfaceController($scope, $http) {
    var interfaceControllerVm = this;
   Initialize();
    function Logout() {
       
        interfaceControllerVm.loading = true;       
        var logouturl = "https://Loouturl.com/famlogout?";
      var loginurl = "https://Loginurl.com";
       window.location.replace(logoutUrl);

    }
}

Please suggest me what’s wrong here

Thanks Sam

Take a look at the window.location.replace docummentation:

I tried below code as per the above article. still not useful.

window.location.replace(
  "https://Loouturl.com/famlogout?",
);
  • Sam

window.location.replace replaces the url, preventing to use back button to visit current page

I am trying below code block.

window.location.replace("https://Loouturl.com/famlogout?");

It’s not preventing browser back button click and redirecting to application prev page on it’s click.

Regards,
Sam

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.