Posts Tagged ‘javascript onclick’

javascript void 0 href onclick

julio 20, 2012

bad:

<a id="myLink" href="javascript:MyFunction();">link text</a>


good:

<a id="myLink" title="Click to do something" href="#" onclick="MyFunction();return false;">link text</a>

better:

<a href="javascript:void(0)" onclick="MyFunction();">link text</a>

http://stackoverflow.com/questions/1070760/javascript-function-in-href-vs-onclick
http://stackoverflow.com/questions/134845/href-tag-for-javascript-links-or-javascriptvoid0