Like the title says, I'd like to be able to perform a different onstatechange
event if the pushState
function is called, instead of the back
function. Or, if the go
function is negative or positive.
Example:
if History.pushState()
or History.go(1)
are called, I want the statechange
event's callback to be forwardPushState
if History.back()
or History.go(-1)
are called, I want the statechange
event's callback to be backwardsPushState
A state is some data related to a page (as the user see it in the browser). If the user wants to be in a certain page, this page is the same, either he is coming from back button click or from forward button click.
PushState pushes a new state in the stack. It has no relationship with back
and go
. Back
and go
are functions to navigate over pushed states in stack. I say this because in your edit, it looks like you are thinking that pushState and go(1) are equivalent.
Maybe if you want to know from which direction the user is coming, you should analyse onstatechange
event to know if it takes any parameter that stores direction, which is not a trivial task IMO.
The main thing I think, is that it has no relationship with the go (-1)
or go(1)
or back
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With