There needs to be a section on how HTML event attribute strings are evaluated. For ex:

<button ... onclick="foo();">

creates a function named "onclick" with the event object as a parameter named event:

function onclick(event) {

See Core_JavaScript_1.5_Reference:Objects:Function#Functions_as_event_handlers.

--Maian 03:30, 8 September 2005 (PDT)

Actually, onclick="foo();" will assign the RESULT of the function "foo" to onclick, unless I am misunderstanding something. --Callek 20:20, 15 September 2005 (PDT)
You're misunderstanding something :) That would make no sense, since most handlers return either nothing (undefined) or a boolean, and you don't set onclick to undefined or boolean. Try alert(button.onclick) for proof. --Maian 00:15, 16 September 2005 (PDT)
Do NOTE my use of () in the "actually" clause there, button.onclick is different from button.onclick(); as in, adding the paren's to the attribute changes its meaning, I'll check this out for sure later, been a while since I played with the HTML side of any script-related pages. Though realize, if I was 100% sure, I would have simply fixed any problem I found. --Callek 22:45, 20 September 2005 (PDT)
Callek, in your example, "foo()" is a string, so you're really misunderstanding (or mistyping) something. --Nickolay 02:31, 21 September 2005 (PDT)

Why is there no description of event.originalTarget ? Versgui 16:21, 20 July 2006 (PDT)

Because no-one wrote it yet. I added them to the list, feel free to put content on those pages. --Nickolay 01:33, 21 July 2006 (PDT)

Is the section on event methods incomplete? See Notes on http://developer.mozilla.org/en/docs...nt.createEvent Jabez

I am working on a Polish translation of the Gecko DOM Ref and after a closer look at docs I've got some suggestions. I think we need at least two things described clearly and completely, in one proper place. These are

  • propagation phases
  • how to register events.

As far as I have seen (maybe I missed something?) there is no clear explanation of propagation phases - what is "bubbling" and "capture", what comes when. The diagram in the introduction is a good resource, but not in this place. I would suggest putting it all in a separate section or separate page.

The second thing is how to register event handlers. Three possible ways of doing it should be clearly explained on one page. I mean element.addEventListener(), element.onsomething properties and HTML onsomething="" attribute. The info about wrapper function for the HTML attribute code should include information about predefined "event" parameter (which is currently in the DOM:event). There is needed a clarification which are pros and cons of those different methods. Something in this direction is in DOM:element.onclick#Notes.

There is also a document.createEvent method which is related to events and could by mentioned in the event model description.

I don't want to criticise, I just think we need a better description of event model, easy to understand for people new to DOM.

My suggestion is to put all important information in one place and to make it complete - just avoid splitting information on different pages. --Jan Dudek 04:59, 3 August 2006 (PDT)

Browser compatibility (notably IE)

A thing I've ended up doing is passing this as a parameter to handlers that are defined in DOM markup. IE won't report the sending DOM element as this when firing an event, so my solution has been this onclick="foo(this, event)". Now in the documentation it says that event is a predefined variable but in the case of IE this would resolve to the window.event property (which is perfectly fine).

I think it's a neat trick which could be exemplified in the article, or shown as to get the both of worlds without having to rely on a lot of clutter. It's IE centric but impose a minimal overhead.

You still have to deal with that object as a non standardized object, but it greatly reduces the amount of code necessary.

--Leidegre 05:49, 16 July 2008 (PDT)

Document Tags and Contributors

Contributors to this page: Leidegre, Jan Dudek, Jabez, Nickolay, Versgui, Callek, Maian
Last updated by: Leidegre,