winder Posted July 29, 2007 Share Posted July 29, 2007 hello. i see that in both firefox and ie, when a link is clicked the default behavior is to scroll back to the top of the page. This is fine in some cases but, in some other cases is disturbing. I'm wandering is it possible (with php, javascript or whatever), to specify not to scroll back to the top of the page for a specific link? To overide this behavior... thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/62308-solved-browser-behavior-when-link-is-clicked/ Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 Are we talking about anchors? http://www.w3schools.com/html/html_links.asp Jump to a named location on a page Quote Link to comment https://forums.phpfreaks.com/topic/62308-solved-browser-behavior-when-link-is-clicked/#findComment-310056 Share on other sites More sharing options...
winder Posted July 29, 2007 Author Share Posted July 29, 2007 hmm... let me explain more.... in a movie details page i have some links that contain some image thumbnails that reloads the same page and places a bigger image in an image placeholder (with javascript). In the same time i pass a variable value with php to show which image is currently shown. The problem is that when the page is long and you need to scroll down to see the thumbnails and the main image (they are always located at the bottom of the movie details page for each movie), then when you click a thumbnail, the image is shown in the placeholder (main bigger image) but the browser scrolls again up. And you need to scroll again down to see the image you clicked... i hope i made my self clear... Quote Link to comment https://forums.phpfreaks.com/topic/62308-solved-browser-behavior-when-link-is-clicked/#findComment-310227 Share on other sites More sharing options...
redbullmarky Posted July 29, 2007 Share Posted July 29, 2007 if you have a # in your href (either just # or #top, #bottom, etc) then this is the normal behaviour as it starts from the top of the page looking for a named anchor. i'm assuming you're using href="#" with the intention of doing some javascript instead of creating a link. in which case, in your 'onclick', put a "return false" in there. <a href="#" onclick="doSomething(); return false">click me!</a> there are several ways to achieve the same, but this seems to be the one that sorts out what you have already Quote Link to comment https://forums.phpfreaks.com/topic/62308-solved-browser-behavior-when-link-is-clicked/#findComment-310268 Share on other sites More sharing options...
winder Posted July 29, 2007 Author Share Posted July 29, 2007 thanks guys for your help! You both solved my problem Quote Link to comment https://forums.phpfreaks.com/topic/62308-solved-browser-behavior-when-link-is-clicked/#findComment-310445 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.