I tried doing it this way but it takes interaction with the screen for it to work, is there any way to make it work without interaction
history.pushState(null, document.title, location.href);
history.back();
history.forward();
window.onpopstate = function () {
history.go(1);
};