xProteuSx Posted January 6, 2009 Share Posted January 6, 2009 I have a PHP based website where some of the pages get quite long, so you need to scroll down and down and down. Now, what I would like is that if someone scrolls down one of the long pages, clicks a link, and hits the back button, the page is there anew, but the visitor is already scrolled down to the point where he clicked on the link. Right now if you hit the back button the you go back a page, but to the top of it. Any ideas how this is done? Quote Link to comment https://forums.phpfreaks.com/topic/139647-back-button-takes-you-to-same-place-on-page/ Share on other sites More sharing options...
redarrow Posted January 6, 2009 Share Posted January 6, 2009 anchor link i think. http://www.w3schools.com/HTML/html_links.asp Quote Link to comment https://forums.phpfreaks.com/topic/139647-back-button-takes-you-to-same-place-on-page/#findComment-730662 Share on other sites More sharing options...
xProteuSx Posted January 6, 2009 Author Share Posted January 6, 2009 No, anchor links is not what I was thinking. Anchor links can be used to get from one part of a page to another part of the same page real quick. I know this, and even use it occasionally. However, this doesn't help me as far as the Back button goes. Quote Link to comment https://forums.phpfreaks.com/topic/139647-back-button-takes-you-to-same-place-on-page/#findComment-730664 Share on other sites More sharing options...
xProteuSx Posted January 6, 2009 Author Share Posted January 6, 2009 You know, this seems to be automatically 'on' in Internet Explorer. Mozilla is fussy, and takes you back to the top of any page you go 'Back' to. I thought it might just be a browser thing, until I realized that on eBay it works, even in Mozilla/Firefox. Quote Link to comment https://forums.phpfreaks.com/topic/139647-back-button-takes-you-to-same-place-on-page/#findComment-730681 Share on other sites More sharing options...
thebadbad Posted January 6, 2009 Share Posted January 6, 2009 Although it may be bad practice, you can use this onclick attribute on the link: <a href="page_url" onclick="history.go(-1); return false;">Back</a> Haven't used it myself before, so I'm not sure how it precisely works, but you could try it out. The elegant solution would be to use anchor links like redarrow suggested. Just add a name attribute to each link on the long page, and then include that name in the back button link on each individual page. Like: Long page (long.php) Bla bla <a href="small.php" name="somename">first link</a> bla bla. More text and links. Individual page (small.php) Some more text. <a href="long.php#somename">Back button<a>. Or simply remove the back button, and force the user to use the browser's back button. That should take them back to exactly where they clicked the link on the long page. Quote Link to comment https://forums.phpfreaks.com/topic/139647-back-button-takes-you-to-same-place-on-page/#findComment-730708 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.