| 5 |
<span class=secno>$1 </span>事象取扱器属性 |
<span class=secno>$1 </span>事象取扱器属性 |
| 6 |
|
|
| 7 |
#en |
#en |
| 8 |
<a href="#html-elements">HTML elements</a> can have <dfn id=event2>event |
<a href=#html-elements>HTML elements</a> can have <dfn id=event-definition>event |
| 9 |
handler attributes</dfn> specified. These act as bubbling event listeners |
handler attributes</dfn> specified. These act as bubbling event listeners |
| 10 |
for the element on which they are specified. |
for the element on which they are specified. |
| 11 |
#ja |
#ja |
| 12 |
<a href="#html-elements">HTML 要素</a>には<dfn id=event2>事象取扱器属性</dfn>を指定することができます。 |
<a href=#html-elements>HTML 要素</a>には<dfn id=event-definition>事象取扱器属性</dfn>を指定することができます。 |
| 13 |
これは指定された属性に対する泡立ち事象聴取器として機能します。 |
これは指定された属性に対する泡立ち事象聴取器として機能します。 |
| 14 |
|
|
| 15 |
#en |
#en |
| 16 |
Each event handler attribute has two parts, an <a href="#event3" |
Each event handler attribute has two parts, an <a href=#event-definitions |
| 17 |
title="event handler content attributes">event handler content |
title="event handler content attributes">event handler content |
| 18 |
attribute</a> and an <a href="#event4" title="event handler DOM |
attribute</a> and an <a href=#event-loop title="event handler DOM |
| 19 |
attributes">event handler DOM attribute</a>. Event handler attributes must |
attributes">event handler DOM attribute</a>. Event handler attributes must |
| 20 |
initially be set to null. When their value changes (through the changing |
initially be set to null. When their value changes (through the changing |
| 21 |
of their event handler content attribute or their event handler DOM |
of their event handler content attribute or their event handler DOM |
| 22 |
attribute), they will either be null, or have an |
attribute), they will either be null, or have an |
| 23 |
<code>EventListener</code> object assigned to them. |
<code>EventListener</code> object assigned to them. |
| 24 |
#ja |
#ja |
| 25 |
各事象取扱器属性は、<a href="#event3" |
各事象取扱器属性は、<a href=#event-definitions |
| 26 |
title="event handler content attributes">事象取扱器内容属性</a>と<a href="#event4" title="event handler DOM |
title="event handler content attributes">事象取扱器内容属性</a>と<a href=#event-loop title="event handler DOM |
| 27 |
attributes">事象取扱器 DOM 属性</a>の2つの部分を持ちます。 |
attributes">事象取扱器 DOM 属性</a>の2つの部分を持ちます。 |
| 28 |
事象取扱器属性は、はじめ、 null に設定されなければ[[MUST:なりません]]。 |
事象取扱器属性は、はじめ、 null に設定されなければ[[MUST:なりません]]。 |
| 29 |
(事象取扱器内容属性または事象取扱器 DOM 属性の変更により) 値が変化した時は、 |
(事象取扱器内容属性または事象取扱器 DOM 属性の変更により) 値が変化した時は、 |
| 32 |
|
|
| 33 |
#en |
#en |
| 34 |
Objects other than <code>Element</code> objects, in particular <code><a |
Objects other than <code>Element</code> objects, in particular <code><a |
| 35 |
href="#window">Window</a></code>, only have <a href="#event4" title="event |
href=#window>Window</a></code>, only have <a href=#event-loop title="event |
| 36 |
handler DOM attributes">event handler DOM attribute</a> (since they have |
handler DOM attributes">event handler DOM attribute</a> (since they have |
| 37 |
no content attributes). |
no content attributes). |
| 38 |
#ja |
#ja |
| 39 |
<code>Element</code> オブジェクト以外のオブジェクト、特に <code><a |
<code>Element</code> オブジェクト以外のオブジェクト、特に <code><a |
| 40 |
href="#window">Window</a></code> は、<a href="#event4" title="event |
href=#window>Window</a></code> は、<a href=#event-loop title="event |
| 41 |
handler DOM attributes">事象取扱器 DOM 属性</a>だけを持ちます (内容属性を持ちませんから)。 |
handler DOM attributes">事象取扱器 DOM 属性</a>だけを持ちます (内容属性を持ちませんから)。 |
| 42 |
|
|
| 43 |
#en |
#en |
| 44 |
<dfn id=event3>Event handler content attributes</dfn>, when specified, |
<dfn id=event-definitions>Event handler content attributes</dfn>, when specified, |
| 45 |
must contain valid ECMAScript code matching the ECMAScript <code |
must contain valid ECMAScript code matching the ECMAScript <code |
| 46 |
title="">FunctionBody</code> production. <a |
title="">FunctionBody</code> production. <a |
| 47 |
href="#refsECMA262">[ECMA262]</a> |
href=#refsECMA262>[ECMA262]</a> |
| 48 |
#ja |
#ja |
| 49 |
<dfn id=event3>事象取扱器内容属性</dfn>は、指定された場合、 |
<dfn id=event-definitions>事象取扱器内容属性</dfn>は、指定された場合、 |
| 50 |
ECMAScript <code |
ECMAScript <code |
| 51 |
title="">FunctionBody</code> 生成規則に一致する妥当な ECMAScript 符号を含まなければなりません。<a |
title="">FunctionBody</code> 生成規則に一致する妥当な ECMAScript 符号を含まなければなりません。<a |
| 52 |
href="#refsECMA262">[ECMA262]</a> |
href=#refsECMA262>[ECMA262]</a> |
| 53 |
|
|
| 54 |
#en |
#en |
| 55 |
When an event handler content attribute is set, its new value must be |
When an event handler content attribute is set, its new value must be |
| 58 |
linked from the activation object of the handler, to the element, to the |
linked from the activation object of the handler, to the element, to the |
| 59 |
element's <code>form</code> element if it is a form control, to the |
element's <code>form</code> element if it is a form control, to the |
| 60 |
<code>Document</code> object, to the <code><a |
<code>Document</code> object, to the <code><a |
| 61 |
href="#window">Window</a></code> object of the <a |
href=#window>Window</a></code> object of the <a |
| 62 |
href="#browsing1">browsing context</a> of that <code>Document</code>. The |
href=#browsing-context>browsing context</a> of that <code>Document</code>. The |
| 63 |
function's <code>this</code> parameter must be the <code>Element</code> |
function's <code>this</code> parameter must be the <code>Element</code> |
| 64 |
object representing the element. The resulting function must then be set |
object representing the element. The resulting function must then be set |
| 65 |
as the value of the corresponding event handler attribute, and the new |
as the value of the corresponding event handler attribute, and the new |
| 74 |
要素がフォーム制御子である場合フォームの <code>form</code> |
要素がフォーム制御子である場合フォームの <code>form</code> |
| 75 |
要素へ、 <code>Document</code> オブジェクトへ、その <code>Document</code> |
要素へ、 <code>Document</code> オブジェクトへ、その <code>Document</code> |
| 76 |
の<a |
の<a |
| 77 |
href="#browsing1">閲覧文脈</a>の <code><a |
href=#browsing-context>閲覧文脈</a>の <code><a |
| 78 |
href="#window">Window</a></code> オブジェクトへと連結されているようなものの本体であるとして解釈しなければ[[MUST:なりません]]。 |
href=#window>Window</a></code> オブジェクトへと連結されているようなものの本体であるとして解釈しなければ[[MUST:なりません]]。 |
| 79 |
この関数は、対応する事象取扱器属性の値として設定されなければ[[MUST:ならず]]、 |
この関数は、対応する事象取扱器属性の値として設定されなければ[[MUST:ならず]]、 |
| 80 |
新しい値は内容属性の値として設定されなければ[[MUST:なりません]]。 |
新しい値は内容属性の値として設定されなければ[[MUST:なりません]]。 |
| 81 |
与えられた関数本体がコンパイルに失敗する場合は、対応する事象取扱器属性は代わりに null |
与えられた関数本体がコンパイルに失敗する場合は、対応する事象取扱器属性は代わりに null |
| 84 |
|
|
| 85 |
#en |
#en |
| 86 |
See ECMA262 Edition 3, sections 10.1.6 and 10.2.3, for more |
See ECMA262 Edition 3, sections 10.1.6 and 10.2.3, for more |
| 87 |
details on activation objects. <a href="#refsECMA262">[ECMA262]</a> |
details on activation objects. <a href=#refsECMA262>[ECMA262]</a> |
| 88 |
#ja |
#ja |
| 89 |
活性化オブジェクトの詳細については、 ECMA 262 第3版の |
活性化オブジェクトの詳細については、 ECMA 262 第3版の |
| 90 |
10.1.6 節と 10.2.3 節を参照してください。 |
10.1.6 節と 10.2.3 節を参照してください。 |
| 91 |
<a href="#refsECMA262">[ECMA262]</a> |
<a href=#refsECMA262>[ECMA262]</a> |
| 92 |
|
|
| 93 |
#en |
#en |
| 94 |
The <a href="#script2">script execution context</a> of the event handler |
The <a href=#script-execution-context>script execution context</a> of the event handler |
| 95 |
must be the <code><a href="#window">Window</a></code> object at the end of |
must be the <code><a href=#window>Window</a></code> object at the end of |
| 96 |
the scope chain. The <a href="#script4">script document context</a> of the |
the scope chain. The <a href=#script-document-context>script document context</a> of the |
| 97 |
event handler must be the <code>Document</code> object that owns the event |
event handler must be the <code>Document</code> object that owns the event |
| 98 |
handler content attribute that was set. |
handler content attribute that was set. |
| 99 |
#ja |
#ja |
| 100 |
事象取扱器の<a href="#script2">スクリプト実行文脈</a>は、 |
事象取扱器の<a href=#script-execution-context>スクリプト実行文脈</a>は、 |
| 101 |
適用範囲鎖の最後の <code><a href="#window">Window</a></code> |
適用範囲鎖の最後の <code><a href=#window>Window</a></code> |
| 102 |
オブジェクトでなければ[[MUST:なりません]]。事象取扱器の<a href="#script4">スクリプト文書文脈</a>は、 |
オブジェクトでなければ[[MUST:なりません]]。事象取扱器の<a href=#script-document-context>スクリプト文書文脈</a>は、 |
| 103 |
設定された事象取扱器内容属性を所有する <code>Document</code> |
設定された事象取扱器内容属性を所有する <code>Document</code> |
| 104 |
オブジェクトでなければ[[MUST:なりません]]。 |
オブジェクトでなければ[[MUST:なりません]]。 |
| 105 |
|
|
| 106 |
#en |
#en |
| 107 |
<dfn id=event4>Event handler DOM attributes</dfn>, on setting, must set |
<dfn id=event-loop>Event handler DOM attributes</dfn>, on setting, must set |
| 108 |
the corresponding event handler attribute to their new value, and on |
the corresponding event handler attribute to their new value, and on |
| 109 |
getting, must return whatever the current value of the corresponding event |
getting, must return whatever the current value of the corresponding event |
| 110 |
handler attribute is (possibly null). |
handler attribute is (possibly null). |
| 111 |
#ja |
#ja |
| 112 |
<dfn id=event4>事象取扱器 DOM 属性</dfn>は、設定時、 |
<dfn id=event-loop>事象取扱器 DOM 属性</dfn>は、設定時、 |
| 113 |
対応する事象取扱器属性を新しい値に設定しなければ[[MUST:ならず]]、 |
対応する事象取扱器属性を新しい値に設定しなければ[[MUST:ならず]]、 |
| 114 |
取得時、対応する事象取扱器属性の値を何であっても (null であっても) |
取得時、対応する事象取扱器属性の値を何であっても (null であっても) |
| 115 |
返さなければ[[MUST:なりません]]。 |
返さなければ[[MUST:なりません]]。 |
| 116 |
|
|
| 117 |
#en |
#en |
| 118 |
The following are the event handler attributes that must be supported by |
The following are the event handler attributes that must be supported by |
| 119 |
all <a href="#html-elements">HTML elements</a>, as both content attributes |
all <a href=#html-elements>HTML elements</a>, as both content attributes |
| 120 |
and DOM attributes, and on <code><a href="#window">Window</a></code> |
and DOM attributes, and on <code><a href=#window>Window</a></code> |
| 121 |
|
|
| 122 |
objects, as DOM attributes: |
objects, as DOM attributes: |
| 123 |
#ja |
#ja |
| 124 |
次に示すのは、すべての <a href="#html-elements">HTML 要素</a>で内容属性としても DOM |
次に示すのは、すべての <a href=#html-elements>HTML 要素</a>で内容属性としても DOM |
| 125 |
属性としても対応しなければ[[MUST:ならず]]、 <code><a href="#window">Window</a></code> |
属性としても対応しなければ[[MUST:ならず]]、 <code><a href=#window>Window</a></code> |
| 126 |
オブジェクトで DOM 属性として対応しなければ[[MUST:ならない]]事象取扱器属性です。 |
オブジェクトで DOM 属性として対応しなければ[[MUST:ならない]]事象取扱器属性です。 |
| 127 |
|
|
| 128 |
#pattern |
#pattern |
| 129 |
Must be invoked whenever an * event is targeted at or bubbles through |
Must be invoked whenever an * event is targeted at or bubbles through |
| 130 |
the element. |
the element. |
| 131 |
#ja |
#ja |
| 132 |
$1 事象が当該要素を対象とするか、泡立ち当該要素を通過する時には常に呼び出されなければ[[MUST:なりません]]。 |
$1 事象が当該要素を対象としているか、泡立って当該要素を通過する時には、 |
| 133 |
|
常に呼び出されなければ[[MUST:なりません]]。 |
| 134 |
|
|
| 135 |
|
#pattern |
| 136 |
|
Must be invoked whenever a * event is targeted at or bubbles through |
| 137 |
|
the element. |
| 138 |
|
#ja |
| 139 |
|
$1 事象が当該要素を対象としているか、泡立って当該要素を通過する時には、 |
| 140 |
|
常に呼び出されなければ[[MUST:なりません]]。 |
| 141 |
|
|
| 142 |
|
#en |
| 143 |
|
The <code title=handler-onerror><a |
| 144 |
|
href=#handler-onerror>onerror</a></code> handler is also used for <a |
| 145 |
|
href=#runtime-script-errors>reporting script errors</a>. |
| 146 |
|
#ja |
| 147 |
|
<code title=handler-onerror><a |
| 148 |
|
href=#handler-onerror>onerror</a></code> 取扱器は<a |
| 149 |
|
href=#runtime-script-errors>スクリプト誤りの報告</a>にも使われます。 |
| 150 |
|
|
| 151 |
|
#en |
| 152 |
|
When an event handler attribute is invoked, its argument must be set to |
| 153 |
|
the <code>Event</code> object of the event in question. If the function |
| 154 |
|
returns the exact boolean value false, the event's |
| 155 |
|
<code>preventDefault()</code> method must then invoked. Exception: for |
| 156 |
|
historical reasons, for the HTML <code>mouseover</code> event, the |
| 157 |
|
<code>preventDefault()</code> method must be called when the function |
| 158 |
|
returns true instead. |
| 159 |
|
#ja |
| 160 |
|
事象取扱器属性が呼び出される時、その引数には当該事象の <code>Event</code> |
| 161 |
|
オブジェクトを設定しなければ[[MUST:なりません]]。関数がブール値の偽そのものを返した場合には、 |
| 162 |
|
事象の <code>preventDefault()</code> メソッドを呼び出さなければ[[MUST:なりません]]。 |
| 163 |
|
例外: 歴史的理由により、 HTML <code>mouseover</code> |
| 164 |
|
事象に関しては、 <code>preventDefault()</code> メソッドは、 |
| 165 |
|
代わりに関数が真を返した時に呼び出されなければ[[MUST:なりません]]。 |
| 166 |
|
|
| 167 |
|
#en |
| 168 |
|
All event handler attributes on an element, whether set to null or to a |
| 169 |
|
function, must be registered as event listeners on the element, as if the |
| 170 |
|
<code title=dom-EventTarget-addEventListenerNS>addEventListenerNS()</code> |
| 171 |
|
method on the <code>Element</code> object's <code>EventTarget</code> |
| 172 |
|
interface had been invoked when the element was created, with the event |
| 173 |
|
type (<var title=dom-event-type>type</var> argument) equal to the type |
| 174 |
|
described for the event handler attribute in the list above, the namespace |
| 175 |
|
(<var title=dom-event-namespaceURI>namespaceURI</var> argument) set to |
| 176 |
|
null, the listener set to be a target and bubbling phase listener (<var |
| 177 |
|
title=dom-event-useCapture>useCapture</var> argument set to false), the |
| 178 |
|
event group set to the default group (<var |
| 179 |
|
title=dom-event-evtGroup>evtGroup</var> argument set to null), and the |
| 180 |
|
event listener itself (<var title=dom-event-listener>listener</var> |
| 181 |
|
argument) set to do nothing while the event handler attribute is null, and |
| 182 |
|
set to invoke the function associated with the event handler attribute |
| 183 |
|
otherwise. (The <var title=dom-event-listener>listener</var> argument is |
| 184 |
|
emphatically <em>not</em> the event handler attribute itself.) |
| 185 |
|
#ja |
| 186 |
|
要素のすべての事象取扱器属性は、 null に設定されている場合も関数が設定されている場合も、 |
| 187 |
|
要素が作成された時に <code>Element</code> オブジェクトの <code>EventTarget</code> |
| 188 |
|
界面の |
| 189 |
|
<code title=dom-EventTarget-addEventListenerNS>addEventListenerNS()</code> |
| 190 |
|
メソッドが事象型 (<var title=dom-event-type>type</var> 引数) は前述の並び中で当該事象取扱属性について示した型、 |
| 191 |
|
名前空間 (<var title=dom-event-namespaceURI>namespaceURI</var> 引数) は |
| 192 |
|
null、聴取器は対象位相と泡立ち位相の聴取器として (<var |
| 193 |
|
title=dom-event-useCapture>useCapture</var> 引数は偽)、 |
| 194 |
|
事象群は既定群として (<var |
| 195 |
|
title=dom-event-evtGroup>evtGroup</var> 引数は null)、 |
| 196 |
|
事象聴取器自体 (<var title=dom-event-listener>listener</var> 引数) は事象取扱器属性が |
| 197 |
|
null の場合はなにもしないとして、それ以外の場合は事象取扱器属性に関連付けられた関数を呼び出すとして |
| 198 |
|
(<var title=dom-event-listener>listener</var> 引数は事象取扱器属性自体では<em>ない</em>と強調しておきます。) |
| 199 |
|
呼び出した場合のように要素の事象取扱器として登録されなければ[[MUST:なりません]]。 |