0

Possible Duplicate:
What does “javascript:void(0)” mean?

I am checking many sites and I have seen that many website creator define inline JS function "javascript:void(0)". I think this is a difining a JS function which does nothing. example from images.google.com the image inside the search box contains.

<a class="gsst_a" href="javascript:void(0)">
         <span id="gs_si0">
             <span class="gssi_a gsst_e" id="qbi">
             </span>
         </span>
</a>

Can anybody explain what is the use of benifit of defining this function even this function does nothing.

Community
  • 1
  • 1
dead programmer
  • 4,223
  • 9
  • 46
  • 77

1 Answers1

1

Some browsers don't render a contents styled like a link (blue underline, hand cursor, etc) unless there's a href attribute present, and if this "no-op" href later gets supplanted by an onclick handler attached to the element, then that's why you might use it.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055