In other words what’s the difference between
onclick="myFunction()"
and
onclick="JavaScript:myFunction()"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
JavaScript:TYPE/LABEL/PREFIX (could not find the actual name for it) in the event handler serves one purpose only:In Internet Explorer (which supported VBScript as a browser language),
IFF the FIRST script on the page is NOT JavaScript, inline JavaScript on the rest of the page had to have
javascript:prefixing it.It is not to be confused with the
javascript:protocol in the href (which, by the way, also should be avoided).href="javascript:..."is only ever needed in old netscapes in the AREA tag. When you see thehref="javascript:void(0)"someone needs to useonclick="....; return false"instead, unless they put it there to alert the user that the link is a javascript driven one. It will fail if JS is turned off.Even better is to remove inline event handlers and use addEventListener – delegate when more than one element that needs the same eventListener.
I looked for the official documentation from msdn, but here are discussions to back me up:
Calling VBScript from Javascript
https://www.webdeveloper.com/forum/archive/index.php/t-135462.html(link not working anymore)Example