You are here: Re: href="javascript:func()" vs href="#" onclick="javascript:func()" « HTML « IT news, forums, messages
Re: href="javascript:func()" vs href="#" onclick="javascript:func()"

Posted by Jim Higson on 06/18/06 10:11

CRON wrote:

>
> Best solution found::::
>
> <a href="#" onclick="func();return false">
>
> This is a handy way to stop the page from jumping around but still run
> the function.

The best way I'd say is to not include any link in the page, but then add it
in using javascript once the page has loaded.

Or, if the link must be created on the server-side, try something like:

<a href="javascript:whatever()" style="display:none" id="js-link">blah</a>
<script type="text/javascript">
var link_ele = document.getElementById( "js-link" );
link_ele.setAttribute( "sytle", "" );
</script>

This way, the link will only be shown if the user has javascript enabled.

--
Jim

 

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

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