Get Popstate Direction? (Forward/Back)

It turns out that Safari creates an event.state element on page load without the need of javascript manually creating it. It’s creating a bit of a cross-browser compatibility issue. I was hoping to rectify this by finding the “direction” of the popstate.

So, when the user clicks the back button, I’m trying to see if there is an event direction variable I can work with to confirm that we are going either “backward” (back button) or “forward” (forward button).

I tried event.direction and getting undefined. Is there a way to get direction?


I actually resolved my error by creating a variable and making it false during page load, then turned the variable true only if a pushState took place. Then checked to make sure variable true before running the script that was giving cross-browser issues.

However, I am still wondering if it is possible to see the direction.