Is there any difference between
<input type="submit" value="Register" onclick="javascript:submitTheForm();">
and
<input type="submit" value="Register" onclick="submitTheForm();">
Should I use javascript: before a JS function call?
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.
javascript:inside anonwhatever=""handler is a no-op. The content of this attribute is always JavaScript sojavascript:defines a label – but outside of aswitchblock or a loop (where you can use it tobreak/continueto the position of the label) it does nothing.However, using inline event handlers is discouraged, there are better ways to register event handlers.
While not mentioned in the question, it’s worth noting that using
javascript:in thehrefattribute does work (and in there it is actually necessary) but is highly discouraged for various reasons:thisdoes not point to the elementSo, if you really have to use inline events, always use
onclick=""etc. withoutjavascript:.