Reply to Re: stopping <a> from loading new page but still performing onclick action

Your name:

Reply:


Posted by Noodle on 09/08/06 09:22

Nick D wrote:
> All of the examples in this thread are depreciated. None of them will
> degrade gracefully. You should ALWAYS use the (<a
> href="action_page.html">Link</a>) Then attach an onload javascript
> function that will run through all link tags and add the proper onclick
> event and removing the traditional "href" properties. This way your
> script will ALWAYS work even if javascript is disabled.
>
> Reference: http://www.w3.org/TR/WCAG10-HTML-TECHS/
>
>
> Good Man wrote:
> > "Nick D" <nick.denardis@gmail.com> wrote in
> > news:1157393471.762756.201500@m79g2000cwm.googlegroups.com:
> >
> > > Sometimes this could cause a problem by jumping to the top of the
> > > page. Another way to do this without making the page jump would be to
> > > put (<a href="javascript:void(0)" onclick="SomeFunction()">)
> >
> > i usually call:
> >
> > <a href="javascript://Click To Change Divs" onclick="changeDiv();">
> >
> >
> > i believe my example is proper coding practice - any href="javascript:xxx"
> > should be avoided at all costs.
> >
> > best,
> > gm

A javascript that run's through and removes all the href's from anchor
tags onload seems a bit complex. Just add "return false" to the end of
the onclick call to stop the href from firing after the javascript has
executed. If javascript is diabled, the link will still work.

e.g.

<a href="http://www.somewhere.com" onclick="alert('hello'); return
false;">click me</a>

[Back to original 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

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