Clear popup event history

I am developing an application that uses views that are added to the story through

history.pushState() Function

Views represent different steps in the form where the user should be able to return to the previous steps and make adjustments, but not redirect without re-posting.

I get reverse navigation by listening to popup events and moving back one step in the called function

The problem is that, since popstate is called history forward in the browser, it becomes available for obvious reasons. But since the history rewind button also fires the popstate event, the result of dragging forward is a transition to another step backward.

Since I do not want the user to be able to go forward, I would like the front story to be cleared.

So my question is basically, is there a way to delete forward history when going through browser history?

+7
source share
1 answer

Check if the user returns from the next step (step 2), for example, you can do this using cookies or localStorage. If it does pushState with the current location (step 1). Unfortunately, he will add another item to the history list for the back button, but will also disable the history rewind button. Step 2 will not appear in the history prehistory list. This is not ideal, but perhaps it is good enough.

+1
source

All Articles