Forum Moderators: open

Message Too Old, No Replies

Is it good to use href="javascript:"?

         

benj0323

12:11 am on Jul 18, 2005 (gmt 0)

10+ Year Member



What's the best way to perform a javascript function in an a tag?

<a href="javascript:whatever()">execute function</a>

or

<a href="#no_where" onclick="whatever()">execute function</a>

Thanks for your help.

ORBiTrus

12:44 am on Jul 18, 2005 (gmt 0)

10+ Year Member



using onclick="whatever(); return false;"

Always.

If possible, provide a link in the href.

If not, use javascript:void(0); to indicate it is javascript.

Also, consider using a tag other than <a> for pure function executors (<button> is the usual).