2015-10-15 69 views
5

是否有人能告诉我在JavaScript中实现HTML事件处理程序与DOM级别0事件处理程序有什么区别?HTML事件处理程序与DOM级别0事件处理程序之间的区别

+0

这可能对您有用:http://stackoverflow.com/q/5642659/830125 –

+0

非常感谢您,但它并没有真正回答这个区别是什么 – Jonny

+0

没有DOM L0规范,该术语仅用于指非标准的广泛功能。然后他们在HTML中被标准化。 – Oriol

回答

0

DOM0事件是在HTML和XHTML规格固有事件定义的声明事件:

内在事件是配合使用元素的属性,可以有当某些动作由执行特定事件发生用户。只有在选择了定义这些元素的模块时,才会将下表中指示的属性添加到它们各自元素的属性集中。

标记语言的某些元素可能具有关联的事件处理程序,它们在发生某些事件时被激活。用户代理需要能够用静态关联的事件处理程序来标识这些元素(即,在内容中关联,而不是在脚本中)。在HTML 4([HTML4],第18.2.3节)中,内部事件由以“on”开头的属性指定:onblur, onchange, onclick, ondblclick, onkeydown, onkeypress, onkeyup, onload, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onreset, onselect, onsubmit, and onunload

Internet Explorer对于使用属性分配的DOM Level 0方法定义的事件处理程序具有正确的作用域,但在使用attachEvent()时不适用。

 
The Level 0 DOM supports the following nodeLists: 

document.images[], which grants access to all images on the page. 
document.forms[], which grants access to all forms on the page. 
document.forms[].elements[], which grants access to all form fields in one form, whatever their tag name. This nodeList is unique to the Level 0 DOM; the W3C DOM does not have a similar construct. 
document.links[], which grants access to all links() on the page. 
document.anchors[], which grants access to all anchors() on the page. 

在本说明书中定义的焦点事件发生相对于彼此的一组顺序英寸

 

Event Name Notes 
1. focusin Sent before first target element receives focus 
2. focus Sent after first target element receives focus 
3. focusout Sent before first target element loses focus 
4. focusin Sent before second target element receives focus 
5. blur Sent after first target element loses focus 
6. focus Sent after second target element receives focus 

以下是事件的典型序列当一个焦点是:当一个焦点的元件之间移动(该顺序假定没有元件被最初集中)以下是事件的典型序列在元素之间移动,包括不推荐使用的DOMFocusIn和DOMFocusOut事件。显示的顺序假定最初没有元素被聚焦。

 
C.2.1 Legacy FocusEvent event order 

Event Name Notes 
1. focusin Sent before first target element receives focus 
2. focus Sent after first target element receives focus 
3. DOMFocusIn If supported 
4. focusout Sent before first target element loses focus 
5. focusin Sent before second target element receives focus 
6. blur Sent after first target element loses focus 
7. DOMFocusOut If supported 
8. focus Sent after second target element receives focus 
9. DOMFocusIn If supported 

HTML事件是在DOM规范定义为HTMLEvents势在必行事件:

<iframe src="https://www.w3.org/DOM/Graphics/dom2-map.svg" width="900" height="400"></iframe> 
 
<img src="https://www.w3.org/TR/DOM-Level-3-Events/images/eventflow.svg" width="400" height="400"/>

参考