In this case, javascript: is label :
Provides a statement with an identifier that you can reference using a break or continue statement.
For example, you can use a label to identify a loop, and then use the break or continue statements to indicate whether the program should interrupt the loop or continue execution.
In this case, it is useless, and instead of javascript you can use any other word.
This is probably only (erroneous!), Because it is usually visible in the href attribute (where javascript: is a pseudo-scheme):
href="javascript:getUserName()"
but it has a completely different meaning in the on* attributes.
Related: Do you need to specify "javascript:" in onclick?
Felix Kling Aug 12 '13 at 11:40 on 2013-08-12 11:40
source share