Jump to content

Archived

This topic is now archived and is closed to further replies.

winder

[SOLVED] browser behavior when link is clicked

Recommended Posts

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 ;)

Share this post


Link to post
Share on other sites

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...  :)

 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.