How to detect hashchange when URL changes from DOM interaction?

1k Views Asked by At

I am using a window.onhashchange event handler to listen for hash change events. It works when I hit the back button, forward button, or enter another hash url in the address bar. However, it does not work when I click on DOM elements that initiate routing. E.g. I click on my homepage logo and go from localhost:3000/#place to localhost:3000/#.

I have not found an answer to this but have seen other people indicating this is not possible, such as the SO post found here. Is there a way to detect any hash change event, regardless of what initiates the hash change?

0

There are 0 best solutions below