2015-10-15 13 views
5

HTMLイベントハンドラの実装とJavaScriptのDOMレベル0イベントハンドラの違いを教えてください。HTMLイベントハンドラとDOMレベル0イベントハンドラの違い

+0

これはあなたに有用であり得る:http://stackoverflow.com/q/5642659/830125 –

+0

はどうもありがとうございましたが、それは本当にwhatbthe違いに答えていないが、何のDOM L0仕様はありません – Jonny

+0

ですこの用語は、非標準的な広範な機能を指すためにのみ使用されていました。その後、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

DOMレベル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イベントはHTMLEventsとしてDOM仕様で定義されて不可欠イベントです:

<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"/>

参照

関連する問題