I usualy found the following code:
<a href="#" onclick="func();return false">click</a>
but sometime my browser go to the top of the page?
Why href="#" is High Priority than onclick?
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.
It isn’t higher priority. The onclick fires and then the browser follows the link.
If you don’t
return false(note spelling) orfuncthrows an error (thus not reaching thereturnstatement) the event won’t be canceled.(As fallbacks for if the JS fails or is disabled go, however, a link to the top of the page is really sucky. Progressive enhancement is the way forward.)