How come javascript:void(0) is creating a 404 page?
If you are writing some JS, you can add something like:

$('a#the_link_ID').click(function(event) {
  event.preventDefault(); // This prevents to follow the link.
  // ...
  // Here goes your code.
});