Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

Nir Benita
PLUS
Nir Benita
Courses Plus Student 3,905 Points

Changing the URL of a single page website on scroll.

Hey guys!

So here's the deal, I'm working on a single page portfolio website.

I have 3 DIVs and I scroll to each one using a Hashtag (#).

I would like to have the URL change when I scroll down the page without having to actually push any buttons, instead, just by scrolling.

Any thoughts on this?

Also, I to learn how to change the class/ID of my menu when reaching a certain point on my page.

2 Answers

Ian Lunn
Ian Lunn
4,558 Points

Check out jQuery Waypoints to execute functions as the page scrolls.

If you use history.js for the URL, in modern browsers you can change the directory of the URL without even requiring a hashtag.

Nir Benita
PLUS
Nir Benita
Courses Plus Student 3,905 Points

This is perfect! Will take me a while to wrap my head around it, but seems like a really great learning experience!