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 19:43

David Dorward wrote:

> Jim Higson wrote:
>
>> <a href="javascript:whatever()" style="display:none"
>> id="js-link">blah</a>
>
>> This way, the link will only be shown if the user has javascript enabled.
>
> Or stylesheets disabled or unavailable.

Like I said in the grandparent post, a better way still is to create the
link altogether in js using DOM. Something like:

<span id="link-placeholder" />
<script type="text/javascript">
var a_ele = document.createElement ( 'a );
a_ele.setAttribute( 'href', 'javascript:whatever()' );
a_ele.appendChild( document.createTextNode( 'blah' ));

var placeholder_ele = document.getElementById( "screensaver-intro" );
placeholder_ele.parentNode.replaceChild( a_ele, placeholder_ele );
</script>

Now, I think that covers all bases?

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

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