Published May 02 2022
Psssst! The 2023 WEB DEVELOPMENT BOOTCAMP is starting on FEBRUARY 01, 2023! SIGNUPS ARE NOW OPEN to this 10-weeks cohort course. Learn the fundamentals, HTML, CSS, JS, Tailwind, React, Next.js and much more! ✨
I’ve had the need to programmatically change the fragment part of a URL
That’s the part after the
# hash symbol.
I was on
index.html and I wanted to change the URL to something like
The reason for this was a bit unusual, but let’s say I had a table of contents but the links weren’t working as I wanted.
Here’s how I did it:
window.location.hash = 'second'