I am redirecting to another page with anchor tag and when the button is clicked I use some javascript to show loading spinner inside the button:
//Example
const a = document.getElementById("some_id");
a.innerHTML = //here I place some divs to show the spinner
My problem is that when I try it on mobile the button is changing its state and redirecting, but when I hit back and go back to the same page, the state is persisted and the button is still in loading state.
I tried using some lifecycle hooks like "beforeunload", "unload" to change the button then, but it's not working. I have also tried to use
document.addEventListener("DOMContentLoaded", function() {//some code to bring back state})
but I still don't have success. This is not a problem on desktop. But on mobile it's acting like SPA and when I hit back the state is persisted...