'history.pushState() not working properly on phone

I have a chap app where user first fills up a form then they are redirected to the chat page. Now the problem is when user clicks the back button they goes back to the login form.

So I used this code to prevent going back,

history.pushState({}, '', "inbox");

history.pushState({}, '', "again-inbox");

window.onpopstate = ()=>{
  history.forward();
}

It works fine on PC but does not work on android browsers.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source