A lot of the time I see people calling javascript functions using colon (:).
Like onclick="javascript:functionname();"
The same function works without javascript: and I’m curious to know when to use javascript: and when not to.
Any suggestions are appreciated.
javascript:prefix is extremely important when you put code to anchorhrefattribute:Whereas in inline event attributes (like
onclick,onsubmit,onmouseover, etc.)javascript:prefix is not important.However, you should note that both approaches given here are not good to implement and you should use alternative ways (e.g as @Paul S. stated in the comments)