Recently I came across something like this
<a href="javascript://">some link</a>
I have no clue what "javascript://" means in that code. Does it mean a protocol named "javascript"?
Any help is greatly appreciated.
Further looking into it, javascript://
is not a valid protocol.
Typically when you want to execute js via a link, you use javascript:doSomething();
.
In this case,
javascript:
mean "execute Javascript code after the :
"//
mean a Javascript comment.It seems to be a placeholder to do nothing, just as javascript:;
would do.
So literally: execute //
(do nothing)
it leads to nowhere as no url is specified.
There are some other approach to the same thing:
href="#"
adds an extra entry to the browser history (which is annoying when e.g. back-buttoning).
href=""
reloads the page
href="javascript:;"
does not seem to have any problems (other than looking messy and meaningless)
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