What is the advantage of using
javascript: fun()
vs
fun()
in an inline event handler function?
What is the advantage of using
javascript: fun()
vs
fun()
in an inline event handler function?
javascript:
is a protocol, to be used when a URL is required, e.g.:
<a href="javascript:fun();return false;">have fun</a>
If the JS is in an event handler attribute you shouldn't place the javascript:
protocol before your code. E.g.:
<a href="#" onclick="fun();">have fun</a>