My understanding is that window.onhashchange() is only really going to see changes to location.hash and not all URL changes. So if we click on an anchor link and go from https://dev.to to https://dev.to#something the location.hash becomes #something. A quick example that can be pasted in the console is:
functionhashHandler(){console.log("The hash has changed! It's now "+location.hash);}window.addEventListener('hashchange',hashHandler,false);
Then just throw a #hash in the address bar and hit enter.
Grew up in Russia, lived in the States, moved to Germany, sometimes live in Spain. I program since I was 13. I used to program games, maps and now I reverse engineer password managers and other stuff
Location
Berlin and Málaga
Education
MS in CS from State Polytechnic University of St. Petersburg
I thought so. The names kinda gives it away, doesn't i? But I was confused by what I read online. It seemed like it's supposed to fire on any URL change. Oh, well. Next time better luck.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My understanding is that
window.onhashchange()
is only really going to see changes tolocation.hash
and not all URL changes. So if we click on an anchor link and go fromhttps://dev.to
tohttps://dev.to#something
thelocation.hash
becomes#something
. A quick example that can be pasted in the console is:Then just throw a
#hash
in the address bar and hit enter.I thought so. The names kinda gives it away, doesn't i? But I was confused by what I read online. It seemed like it's supposed to fire on any URL change. Oh, well. Next time better luck.