Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
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 |