I have some code that is giving me problems.
This one:
onclick="return my_Check();"
and then this one:
onclick="my_Check();"
My question is, Isn’t this the same thing?
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.
No, they’re not the same. The browser internally uses the string value of “onclick” attributes to construct a function:
Thus, adding the
returnkeyword means that the handler function will return a value to the browser after it’s completed its work on being called. That’s important if the handler wants to prevent the browser from doing any “native” action in response to the event: it can returnfalseto tell the browser to do nothing.edit — I got the argument order backwards but it’s fixed now