Outbound Link Summary:
23 years ago
p3k dots

strange, in the last time i got more and more confused about <a href="#"> tags... they are mainly used when there are other javascript handlers involved as tag parameters (e.g. <a href="#" onclick="alert('duh!');">). not every, but many browsers certainly will execute the javascript, however often scroll up to the top of a page which is sometimes really annoying. this can be avoided by 3 alternative approaches:

  1. putting the javascript command inside the href parameter: <a href="javascript:alert('duh!');">
  2. using the void() function instead of the hash: <a href="javascript:void(0);" onclick="alert('duh!');">
  3. creating a function called nothing() (or the like) with an empty function body and using this instead of the hash: <a href="javascript:nothing();" onclick="alert('duh!');"> (recommended for older browsers).