Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
kristinpruter
8,048 PointsLinking to anchor on a different page that uses horizontal layout
I have some links on a home page that I want to go directly to anchors on a different page, but that different page uses a horizontal layout (a series of article tags floated left). The typical <a href="otherpage.php#anchor"> isn't working and I realized it's because I have a horizontal layout so the anchor is already at the top of the page. I've found some information on how to use jquery to scroll horizontally to an anchor within the same page but can't quite figure out how to go to an anchor on a different page.
3 Answers
Anthony Garritano
Courses Plus Student 2,165 PointsYou want the LocalScroll plugin. See the demo: http://demos.flesler.com/jquery/localScroll/#section3c
See how it auto-scrolls to the section?
EDIT: Sorry, Chrome started acted on me and then the page froze. I guess it posted multiple times! Anywho, if you need more info, post back and I'll see what I can do.
Anthony Garritano
Courses Plus Student 2,165 PointsYou want the LocalScroll plugin. See the demo: http://demos.flesler.com/jquery/localScroll/#section3c
See how it auto-scrolls to the section?
Anthony Garritano
Courses Plus Student 2,165 PointsYou want the LocalScroll jQuery plugin: http://demos.flesler.com/jquery/localScroll/#section3c
When viewing that link it auto-scrolls you to the section you want. I have some experience with this plugin (albeit it was a long while ago), post back if you need help with it.
kristinpruter
8,048 PointsOkay, thanks, I found this but thought it would only work within the same page. I'll give it a try.
Adam Sackfield
Courses Plus Student 19,663 PointsAdam Sackfield
Courses Plus Student 19,663 PointsI am no JS expert. But here are my thoughts, could you not add the #section to the link via JS so when it is clicked it adds the anchor to the url and then when the new page loads your jQuery smooth scroll thing will auto slide to the correct place. Not even sure that makes sense as it left my mind.