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 Jonathan N. Little on 06/18/06 20:17

Jim Higson wrote:
> 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.
> JaavScip
> 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?
>

Well to be precise you only use JavaScript in that post to remove the
element's styling that was hiding it...not to create the link.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

 

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

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