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 8161821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:34:47+00:00 2026-06-06T18:34:47+00:00

Quick question about JavaScript event objects – how does JavaScript know when I’m trying

  • 0

Quick question about JavaScript event objects – how does JavaScript know when I’m trying to pass an event variable to a function? For example, when I define an onclick handler like so:

<button onclick='SendMessage(event)'></button>

Does JavaScript pass the event variable just because I named it "event"? If so, what other variable names does it reserve for the purpose of passing event variables? (e? ev? etc..)

If this is the case, can they be covered by naming local or global variables "event", "e", etc.. ?

  • 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-06-06T18:34:48+00:00Added an answer on June 6, 2026 at 6:34 pm

    It must be called event in an inline event. event is not a keyword and is not a reserved word in JavaScript; it is merely the variable name the early Netscape engineers decided upon.

    The inline text supplied for the event is effectively wrapped 1 as:

    function (event) {
       // the inline code
    }
    

    IE uses the window.event property to pass event information, but the names coincide so using event will fallback through the normal JavaScript variable resolution as appropriate.

    Of course, if attaching a function object directly then the event variable, because it’s just the first parameter, can be named whatever is desired. Unfortunately IE’s window.event approach must be dealt with as well, and calling the argument event doesn’t address it.

    elm.onclick = function (my_event_name) {
        my_event_name ||= window.event // for IE
        ...
    }
    

    (I would recommend avoiding inline events as much as possible and using a library that unifies/simplifies events.)

    Happy coding!


    1 This behavior is covered in detail in HTML 5: Event Handlers, Event handler content attributes:

    [inline event, e.g onclick, text] must contain valid JavaScript code which, when parsed, would match [a function] production ..

    Using the script execution environment created above, create a function object .. Let the function have a single argument called event.

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

Sidebar

Related Questions

Quick question about using IQueryable objects. Can I do something like that and if
I have quick question about text parsing, for example: INPUT=a b c d e
quick question. I am trying to use either javascript, jquery, or php to make
Quick question about EJB 3 stateless bean jndi lookup from context. Does context.lookup(myBean) return
just one quick question about the select event of the jQuery UI Tabs $(
quick question about Heroku. My app is using a gem called opentok. To function
Just a quick question about hover events, How can I send a hover event
Quick Question. Should we put Javascript in the HREF or use onClick (event)? Are
I've been broadening my horizons learning javascript and I have a quick question about
Quick question about gem installation -- when I use bundle install I know it

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.