Is there a way to make a null link besides these methods?
<a href="javascript:;">Example</a> <a href="javascript:void(0);">Example</a> <a href="#">Example</a>
I don't mind something that makes the page jump to the top but I don't want it to alter the URL in the address bar. The ideal link would be one as similar as possible to the ones featured on navigation boxes on Wikipedia but there is much more to that link than meets the eye as it has a pretty large script associated with it. I'm just looking for something to put into the a
tag.
Thanks in advance.
a target=”_blank” Open in New Browser Tab (or Window) The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank" , the linked document will open in a new tab or (on older browsers) a new window.
If the parser is unable to find a complete linkage for a sentence - one which links all the words together according to the requirements of the words - it begins to use "null-links". It begins by trying to parse the sentence, ignoring one word.
a javascript:void(0) works nicely. If it doesn't link anywhere it's not really a link... For that reason I prefer cursor: pointer; over javascript:void(0) and also because if JavaScript is disabled, the link will break.
To make an anchor tag refer to nothing, use “javascript: void(0)”.
You just want something you can shove in the <a>
tag? OK:
<a href="#" onclick="return false;">Example</a>
Combine it with any of the href=
methods from your question.
Given that a link that doesn't go anywhere is fairly useless, can I assume you want to kick off some JavaScript function when the link is clicked? If so, do this:
<a href="#" onclick="yourFunctionHere(); return false;">Example</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With