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

PHP

Adam Smallman
Adam Smallman
318 Points

I don't know if this is possible but can some one take a look and let me know what you think.

when a user clicks on a link say in the middle of the home page and then from the new page navigates back to the home page

is it possible to some how navigate the user to the middle of the page where they clicked on the link ?

Here is the link to my site http://bro-creative.com

Click on the first image within the Featured Work section on the home page and then click on the cross icon at the top right to navigate back to the home page. As you can see you get taken to the top of the home page. I want users to be navigated back to the Featured Work section, is that possible ?

Thanks

Adam

1 Answer

Joe Bruno
Joe Bruno
35,909 Points

Hey Adam,

It is possible, but it wouldn't be easy given your current set up. With your current architecture - going off a simple look through without directly inspecting your php or testing something myself - I would think this is possible using internal links.

<a href="#featured-work">Click Me</a>

<div id='featured-work>Section</div>

However, since your navigating to another page, you would need to use javascript and ajax to submit the value of the link clicked into a php function that dynamically insert the correct internal link on the page that user navigated to. That would be the hard way.

An easier way, perhaps, would be to use ajax to dynamically load or show a modal window with the desired content and overlay it with a higher z-index onto the current page. Since you are not leaving the current page, once the modal window was closed, the user would still be at the same spot on the page.

Hope that helps.