Make the pound sign (#) to not appear in address bar!

  • 1
  • Idea
  • Updated 8 years ago
Hello everyone! Do you have a JavaScript code with a link and you use href="#" in it but when you click it the JavaScript code runs, yet it puts a # after the URL in the address bar? Well, there's an easy fix!

Here it is:

<a href="#" onclick="YOUR-JavaScript-FUNCTION-OR-CODE;return false;">Run JavaScript Code</a>

You see? All it is, is return false; right after the last ; in the onclick.

Remember, "YOUR-JavaScript-FUNCTION-OR-CODE" is the actual function you are running in JavaScript. Replace it with that function or code.

It's very easy! This makes it look better, than using javascript:void() in the href!

I hope this helps!

Nathan
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
  • happy

Posted 8 years ago

  • 1
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Thank you for sharing Nathan!
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
No problem! :)