3

What is the difference between javascript:// and javascript:void(0) ?

<a href="javascript://" class="button toggle-filters">Filters</a>
canadadry
  • 8,115
  • 12
  • 51
  • 68
  • possible duplicate: http://stackoverflow.com/questions/3666683/href-javascript-vs-href-javascriptvoid0 – cori Oct 30 '11 at 13:08

2 Answers2

2

javascript:// runs JavaScript that has no statements

javascript:void(0) runs JavaScript that evaluates the statement 0 and then returns undefined.

so javascript:// is much similar to javascript:;

Neither should be used.

Harsh Baid
  • 7,199
  • 5
  • 48
  • 92
2

Previous two answers cover the direct answer to your question, but on a separate track I think you should consider using neither of them. Assuming you're using the anchor tag to illustrate to the user that there's an action they can take by clicking on that text, there are multiple mechanisms for illustrating that, and semantically an anchor tag should illustrate a destination, not an activity.

See this previous answer, and this one.

Community
  • 1
  • 1
cori
  • 8,666
  • 7
  • 45
  • 81