some link I do not know what "javascrip...">

What does javascript: // mean?

I recently came across something like this

<a href="javascript://">some link</a> 

I do not know what "javascript: //" means in this code. Does this mean a protocol called "javascript"?

Any help is greatly appreciated.

+7
source share
2 answers

Further, javascript:// not a valid protocol.

Usually, when you want to execute js by reference, you use javascript:doSomething(); .

In this case

  • Let javascript: means "execute Javascript code after : "
  • And let // mean Javascript comment.

The placeholder seems to be doing nothing, just like javascript:; .

So literally: execute // (do nothing)

+11
source

this causes the URL not to be specified.

There is another approach to the same thing:

href="#" adds an extra entry to the browser history (which is annoying when, for example, feedback).

href="" reloads the page

href="javascript:;" doesn't seem to have any problems (other than finding a messy and pointless)

+2
source

All Articles