In this case javascript:
is a label:
Provides a statement with an identifier that you can refer to 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 a program should interrupt the loop or continue its execution.
It is of no use in this case and instead of javascript
you could use any other word there.
It is probably only (mistakenly!) used because one typically sees this in the href
attribute (where javascript:
is a pseudo-scheme):
href="javascript:getUserName()"
but it has a totally different meaning in on*
attributes.
Related: Do you ever need to specify 'javascript:' in an onclick?