Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:36:55+00:00 2026-05-24T06:36:55+00:00

This may be a subjective question. If so please close it. Does onclick count

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:36:57+00:00Added an answer on May 24, 2026 at 6:36 am

    I’m not sure what you’re asking, but I’ll have a go anyway.

    The onclick attribute 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’s click event) 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 onclick DOM property of an element via JavaScript:

    1. Add a JavaScript file to your page, via the <script src=""> tag.
    2. In that file, set some code to run on page load (or when the DOM is ready, which is a whole other topic in itself).
    3. Have that code add an onclick handler function to an HTML element.

    E.g. if your HTML looked like this

    <a id="needs_onclick">I need an onclick handler</a>
    

    Then you could add an onclick handler to the link like this:

    window.onload = function(){
        document.getElementById("needs_onclick").onclick = function(){
            alert("Clicked!");
        }
    }
    

    This approach would not be described as “embedded JavaScript”, as it uses the onclick DOM property, not the onclick attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may be subjective but i just want to know when to use
I think this question may end up being a bit subjective so I'm marking
Hopefully this question isn't as subjective as I think it may be. I have
This question may be seen as subjective, but I'd like to ask SO users
This may be a subjective question leading to deletion but I would really like
This may seem like a dumb question, or even subjective, but I'm not sure
Stack is warning me this is a subjective question, and will likely be close,
This may be a subjective question, I am new here so keep that in
I realize this may be subjective, so will ask a concrete question, but first,
This may be a purely subjective question (if no organization has attempted to standardize

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.