All DOM events with supported elements?
Is there a list of all JavaScript events (onClick()
, onMouseDown()
et cetera) with information on which elements are valid?
(For example, the onBlur
event is not valid on non form-events in most browsers other than IE.)
I'm aware that a good de开发者_JAVA百科al is 'common sense' (how would you focus()
on a paragraph), but I've found that relying on common sense alone in development rarely gets you far. :)
From the source itself: http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html
Look under the event, and the "target" describes eligibility: http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#event-type-load
Anything further than that is not defined in the spec, and thus, not considered invalid. Like you said a lot of it is common sense and left up to your implementation.
There are good tidbits though which could provoke further research:
A host language may define specific elements which may or may not receive focus, the conditions user which an element may receive focus, the means by which focus may be changed, and the order in which the focus changes. For example, in some cases an element might be given focus by moving a pointer over it, while other circumstances might require a mouse click; some elements might not be focusable at all, and some might be focusable only by special means (clicking on the element), but not by tabbing to it. Documents may contain multiple focus rings. Other specifications may define a more complex focus model than is described in this specification, including allowing multiple elements to have the current focus.
I find that the Microsoft documentation is very clear on what event an element has, and also which elements an event is supported for.
From the list of HTML elements you can find for example the div element that has a list of all event available. From there you can for example find the onblur event that has a list of all elements that it applies to.
Note that this is not a web standard, but the documentation for a specific browser. However, there is clear information on each page whether the item is part of the standards or not.
Does the W3C JavaScript and HTML DOM Reference help? You can specifically drill down by event and find out which tags support which, etc.
精彩评论