You are here: Re: onClick() on an anchor that doesn't force the page to jump to the top? « HTML « IT news, forums, messages
Re: onClick() on an anchor that doesn't force the page to jump to the top?

Posted by Neredbojias on 10/06/76 11:42

With neither quill nor qualm, Aaron Freeman quothed:

> I have a javascript swap image funciton that's called when a user clicks
> on an image wrapped by an anchor. The anchor points to "#", but the
> problem is that the image is below the fold, and when the user clicks
> on the image, the image swaps but the page links to "#" and scrolls the
> page to the top.
>
> So it looks like:
>
> <a href="#" onClick="function()"><img src="image.gif"></a>
>
> If I place the onClick on the image itself, the swap will work without
> jumping the page, but the cursor won't change to indicate a "hot" image.
>
> Is there an easy solution here?

Easy? How about right?

What if the proverbial user has javascript disabled? He should get
something, shouldn't he?

<a href="bigimage.gif"><img src="image.gif" alt=""></a>

Notice the 'alt=""'. It is required, and it's good if there's some
meaningful text between the quotes.

Now, if you want to do the swap thing (for whatever reason,) here is the
same line with the added inclusion.

<a href="bigimage.gif" onClick="function();return false;"><img
src="image.gif" alt=""></a>

--
Neredbojias
Contrary to popular belief, it is believable.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация