What is the difference between onclick="javascript:myfun()" and onclick="myfun()" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the difference between onclick="javascript:myfun()" and onclick="myfun()"

I have been doing some research but I have failed to find a satisfying answer for this.

31st May 2017, 5:24 AM
Chad Tims
Chad Tims - avatar
3 Answers
+ 5
Nothing. javascript:myfun() would call the function myfun() whilst myfun() would call the function myfunc()
31st May 2017, 5:31 AM
Complex
Complex - avatar
+ 2
Yep, no difference, I'm not sure but I think you can also do php: or something, it woulf be pointless if they add javascript: if theres no other languages included
3rd Jun 2017, 4:30 AM
Complex
Complex - avatar
+ 1
meaning there is no difference
1st Jun 2017, 5:05 AM
Chad Tims
Chad Tims - avatar