Is there any reason to use one of the following more than the others:
<input type="button" value="b1" onclick="manageClick(this)" /> <input type="button" value="b2" onclick="manageClick(this);" /> <input type="button" value="b2" onclick="manageClick(this);return false;" /> <input type="button" value="b3" onclick="return manageClick(this);" /> <input type="button" value="b4" onclick="javascript:return manageClick(this);" />
And please do not spend your valuable time to tell me to use jQuery or attachEvent
/addEventListener
. It’s not really the objective of my question.
Advertisement
Answer
There’s no difference at all between the first two, in this specific situation the semicolon is optional.
The third one will prevent any default action from occurring, which the first two won’t.
The fourth will prevent the default action or not depending on the return value of manageClick
.
The fifth one is incorrect.
(And wherever suitable, use attachEvent
/addEventListener
— ducks and runs)