Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
I’ve had the need to programmatically access the fragment part of a URL, the part of the URL after the # hash symbol.
For example if the URL is index.html#second I want second back.
Here’s how I did it:
const fragment = window.location.hash Lessons in this unit:
| 0: | Introduction |
| 1: | The URL object |
| 2: | URLSearchParams |
| 3: | ▶︎ Get the URL fragment |
| 4: | Set the URL fragment |
| 5: | The Navigator object |