Is there an event that fires when any part of the URL changes?
URL change detection has been set many times, but common answers are deprecated (~ 2010).
Summary of existing answers:
You can use popstatefor some situations (it works for all URL changes).
You can use onbeforeunloadit when a page moves (and unloads its resources).
You can use the event hashchangeto view hash fragment changes.
Otherwise, the usual answer will still be poll for changing window.location.
Is the survey the best solution in 2016 ? It's amazing that there is no event for this, given the other improvements in locationand its API, so I ask this question.
Don p source
share