This may be a subjective question. If so please close it.
Does onclick count as embedded JavaScript?
Or is it just usually the method called that’s actually the JavaScript part?
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.
I’m not sure what you’re asking, but I’ll have a go anyway.
The
onclickattribute that you can add to HTML elements (i.e.<a onclick="">) is HTML. However, its value is JavaScript that gets run when the user clicks on the element. That JavaScript (along with the association between that JavaScript and the HTML element’sclickevent) is indeed embedded in the HTML page, meaning you have to change your HTML page to change the JavaScript (or remove the association).To avoid embedding JavaScript into your HTML page, you can instead add a handler function to the
onclickDOM property of an element via JavaScript:<script src="">tag.onclickhandler function to an HTML element.E.g. if your HTML looked like this
Then you could add an
onclickhandler to the link like this:This approach would not be described as “embedded JavaScript”, as it uses the
onclickDOM property, not theonclickattribute.