What's the purpose (if any) of "javascript:" in event handler tags?

javascript

Solution

Probably nothing in your example. My understanding is that `javascript:` is for anchor tags (in place of an actual `href`). You'd use it so that your script can execute when the user clicks the link, but without initiating a navigation back to the page (which a blank `href` coupled with an `onclick` will do).

For example:

<a href="javascript:someFunction();">Blah</a>

Rather than:

<a href="" onclick="someFunction();">Blah</a>

Problem

I've been making a concerted effort to improve my javascript skills lately by reading as much javascript code as I can. In doing this I've sometimes seen the `javascript:` prefix appended to the front of event handler attributes in HTML element tags. What's the purpose of this prefix? Basically, is there any appreciable difference between: ``` onchange="javascript: myFunction(this)" ``` and ``` onchange="myFunction(this)" ``` ?

Original source