简体   繁体   English

所有具有受支持元素的 DOM 事件?

[英]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?是否有所有 JavaScript 事件( onClick() 、 onMouseDown onMouseDown()等等)的列表以及关于哪些元素有效的信息?

(For example, the onBlur event is not valid on non form-events in most browsers other than IE.) (例如, onBlur事件在除 IE 以外的大多数浏览器中对非表单事件无效。)

I'm aware that a good deal 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.我知道很多事情都是“常识”(你会如何focus()一个段落),但我发现在开发中仅仅依靠常识很少能让你走得更远。 :) :)

From the source itself: http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html来自来源本身: 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查看事件,“目标”描述了资格: 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.有些元素可能根本无法聚焦,有些可能只能通过特殊方式(单击元素)而不是通过 Tab 键来聚焦。 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.其他规范可能会定义比本规范中描述的更复杂的焦点 model ,包括允许多个元素拥有当前焦点。

I find that the Microsoft documentation is very clear on what event an element has, and also which elements an event is supported for.我发现Microsoft 文档非常清楚地说明了元素具有什么事件,以及事件支持哪些元素。

From the list of HTML elements you can find for example the div element that has a list of all event available.HTML 元素的列表中,您可以找到例如包含所有可用事件列表的div 元素 From there you can for example find the onblur event that has a list of all elements that it applies to.例如,您可以从那里找到onblur 事件,其中包含它适用的所有元素的列表。

Note that this is not a web standard, but the documentation for a specific browser.请注意,这不是 web 标准,而是特定浏览器的文档。 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? W3C JavaScript 和 HTML DOM 参考有帮助吗? You can specifically drill down by event and find out which tags support which, etc.您可以专门按事件向下钻取并找出哪些标签支持哪些等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM