Jump to content

[SOLVED] browser behavior when link is clicked


winder

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

Link to comment
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...  :)

 

 

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.