We have a need to have an to have href="javascript:void(0);" so that some action can take place on the page without refreshing the page. HOwever, this is generating a 404 page and we need assistance in how to best get rid of the 404 but also keep the functionality so that the action can take place without page refresh.

Code in question:

<a href="javascript:void(0);">Some action</a>

1 Answer 1


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.
  • would it also work if I add rel="nofollow" to the <a> tag to prevent search engines from following the link? Commented Dec 6, 2016 at 5:54
  • Yes @sf_admin819, it will work. Commented Dec 6, 2016 at 13:11
  • it looks like both method work! marking as best answer for others to see in hopes it helps them as well. Commented Dec 6, 2016 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.