This means it’ll do practically nothing. It’s an attempt to have the backlink not ‘navigate’ anywhere. But it really’s not the best way.
The challenge with this is always that one or One more inevitably ends up by using a javascript mistake, and an anchor with the onclick javascript mistake always finally ends up next its href. Usually this winds up being an bothersome jump to the very best with the page, but in the situation of web sites employing , is taken care of as , resulting in an unforeseen navigation.
Since the ingredient is just not acting being a hyperlink, the best option in these cases is not really employing an element but a and supply the desired backlink-like design and style.
void can be an operator that is definitely used to return a undefined worth And so the browser won't be capable of load a new website page.
then an notify message will present up without loading a fresh web site, and that is due to the fact warn is really a purpose that returns a null value. Which means in the event the browser attempts to load a fresh site it sees null and it has nothing at all to load.
However, if The end result is undefined, then the browser stays on the identical web page. void(0) is simply a brief and simple script that evaluates to undefined.
In some predicaments, it is crucial to return undefined instead of the results of an expression. Then void can be employed to discard that outcome. Just one this kind of situation includes javascript: URLs, which needs to be prevented for links, but are beneficial for bookmarklets.
Some developers use href='#' for the same reason, but this leads to the browser to jump to the highest in the site, which is probably not needed. And he couldn't only go away the href blank, because href='' is actually a backlink again to The existing page (ie it triggers a website page refresh).
When the browser isn't going to support JS, the hash mark primarily turns the backlink more info into a no‑op. See also unobtrusive JavaScript.
If you write javascript: on its own there is not any script getting executed, so the results of that script execution can also be undefined
Hence the href="#" onclick="return Fake;" is standards compliant though href="javascript:void(0)" will not be, since there isn't any Formal common that specifies what that should do.
There are ways about these items. Making use of an empty bit of Javascript code within the href is one of them, and although it isn't the best solution, it does work.
I used to be looking for a solution that doesn't refresh internet pages but opens menu products on Ipads and phones.
Old thread but imagined I might just include that The rationale builders use this construct will not be to create a lifeless backlink, but mainly because javascript URLs for many cause will not go references for the Lively html element appropriately.