Conversation
|
Preview URLs (1 page) (comment last updated: 2026-03-07 07:37:20) |
| } | ||
|
|
||
| showEventProperties(event); | ||
| onload = showEventProperties; |
There was a problem hiding this comment.
| onload = showEventProperties; | |
| window.addEventListener("click", showEventProperties); |
There was a problem hiding this comment.
Ok, that would introduce three changes:
-
window.addEventListenerinstead of theonloadproperty. That is fine. After all,addEventListeneris the recommended way. I had used theonloadproperty, because currently many pages on MDN use them, and I had thought that for brevity or in examples, event properties may be preferred. -
Make the global object explicit (
window.). That's fine, too. -
"click"instead of"load". That would not fit the preceding text that explains the example. IMO, that text and the load event are fine. I am in favor of sticking to the load event.
There was a problem hiding this comment.
3.
"click"instead of"load". That would not fit the preceding text that explains the example. IMO, that text and the load event are fine. I am in favor of sticking to the load event.
I prefer click because it contains non-trivial properties such as coordinates, plus it can fire many times. load events are also generally frowned upon in MDN because code examples used to abuse them while top-level code works just fine, so sometimes I go around and remove unnecessary load event listeners. It's best if we can avoid them where we can to make the auditing easier. You can update the preceding text.
There was a problem hiding this comment.
Ok, now the click event is used.
The last example (Displaying event object properties) had an erroneous line. The event handler was not actually registered. Apart from that, now the example uses the click event instead of the load event. The table now has a little margin at the top, so that several tables (after several click events) can be discerned more easily.
|
The text had a "double |
The last example (Displaying event object properties) is meant to "to display all the properties of the onload event object and their values". But the example did not register the appropriate event handler; instead it had an erroneous last line.