HI,
For a tag, you can execute javascript through href or onclick.
When should I use onclick instead of href?
for me, only advantage I get with onclick is that you can hide javascript function name and parameters from your visitors.
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.
Ideally you won’t use either. Ideally your link is a normal hyperlink with an
hrefvalue referencing a fragment (#foo) or URL. Ideally the link would just work as-is without Javascript, too.You’d then use unobtrusive Javascript that attaches itself to links or other DOM elements as needed and only if Javascript is available: