イベントハンドラーの値を設定

イベントハンドラー (DOM)

[34] DOMイベントハンドラー (event handler) は、 オブジェクト要素属性として1つ指定できる簡易版のイベントリスナーです。

[39] オブジェクトにあるものをイベントハンドラーIDL属性 (event handler IDL attribute) (旧・イベントハンドラーDOM属性 (event handler DOM attribute) )要素にあるものをイベントハンドラー内容属性 (event handler content attribute) といいます >>35

[61] イベントハンドラー属性名は、イベント名on を付けたものです。

[62] 例えば click イベント属性名onclick となります。

仕様書

意味

[97] イベントハンドラーは、イベントリスナーの特殊形です。 イベントハンドラーは特定の対象となるオブジェクトについて、 特定のイベント型に関する、 非捕獲フェーズ (bubbling フェーズまたは対象フェーズ) のイベントリスナーとして働きます。

[215] イベントハンドラー特性
イベントハンドラーイベント型 (event handler event type) >>35
イベントハンドラーイベント型
名前 (name)
イベントハンドラーイベント型の前に on をつけたもの >>35属性名として使われます。
イベントハンドラーIDL属性
>>200
(value)
>>38
オブジェクト (object)
>>41
初回設定済み
非null設定済み

[98] 例えば click イベントに対応するイベントハンドラーの名前は onclick となります。 Window オブジェクトには onclick 属性があります。また a 要素にも onclick 属性があります。

[37] 任意のイベント型の名前に on をつければ良いものではなく、 仕様で定義され、利用者エージェントが実装しているイベントハンドラーのみ機能します。

[99] 例えば foobar というイベント型はどの仕様でも定義されていないので、 onfoobar 属性を設定しても、 (著者が特定の Webページのみで使われる独自のイベント型として使うのは自由ですが、) foobar イベントdispatch されたときに呼び出されるわけではありません。

[100] 更に、 DOMContentLoadedHTML Standard で定義されているイベント型ではありますが、 onDOMContentLoaded というイベントハンドラーはどこでも定義されていないので、 そのような属性を設定しても、 dispatch されたときに呼び出されるわけではありません。

イベント対象オブジェクト

[41] ほとんどの場合、イベントハンドラーIDL属性はその文脈オブジェクトイベントハンドラーに、 イベントハンドラー内容属性はその要素イベントハンドラーに対応します。

[106] 例外的に、 body 要素frameset 要素イベントハンドラーIDL属性イベントハンドラー内容属性の一部は、 Window オブジェクトイベントハンドラーに対応します。 Window に属さない body 要素のように、 対応するオブジェクトが存在していないイベントハンドラーIDL属性 >>35イベントハンドラー内容属性も存在します。

[36] HTML Standard は、「イベントハンドラーIDL属性が存在しないオブジェクトイベントハンドラーを晒す場合」 という形で対応するオブジェクトが存在しない状態の動作も規定しています >>35イベントハンドラー内容属性の場合はなぜか明言されていません。

イベントハンドラー IDL 属性

[40] イベントハンドラーIDL属性は、特定のイベントハンドラーに対応すると定義されている IDL属性です。 イベントハンドラーIDL属性属性名は、イベントハンドラー名前と同じです (つまり on + イベント型です)。

[129] すべてのイベントハンドラーイベントハンドラーIDL属性があります。


[200] イベントハンドラーIDL属性は、原則として EventHandler です。

[75] EventHandler は、 コールバック関数または null です。 コールバック関数以外が指定された時は、 null とみなされます (TreatNonCallableAsNull)。 コールバック関数は、 Event 1つを引数とし、任意 (any) の返り値を持つものです。 >>35

[76] 例外として、 onerrorOnErrorEventHandler, onbeforeunloadOnBeforeUnloadEventHandler です。 OnErrorEventHandlerエラーの報告用の引数を取ることもでき、 OnBeforeUnloadEventHandlerDOMString または null を返り値とします >>35

[105] JavaScript では、 FunctionErrorHandler 等のコールバック関数として使うことができます。

取得器

[42] イベントハンドラーIDL属性取得器は、 そのイベントハンドラーイベントハンドラーについて、 次のようにしなければなりません >>35

  1. [204] イベントハンドラーオブジェクトnull でない場合、
    1. [203] イベントハンドラーの現在値を取得した結果を返します。
  2. [205] それ以外の場合、
    1. [206] null を返します。

設定器

[46] イベントハンドラーIDL属性設定器は、 そのイベントハンドラーイベントハンドラーについて、 次のようにしなければなりません >>35

  1. [201] 新しい値を、指定された値を本IDL属性と解釈した結果に設定します。
  2. [83] 新しい値イベントハンドラーの値を設定します。

イベントハンドラー内容属性

[47] イベントハンドラー内容属性は、特定のイベントハンドラーに対応すると定義されている内容属性で、 名前空間null名前空間で、局所名イベントハンドラー名前です >>35

[130] イベントハンドラー内容属性HTMLSVGXUL要素で定義されています。 イベントハンドラー内容属性があってイベントハンドラーIDL属性がないケースは今のところありません。 要素イベントハンドラーイベントハンドラー内容属性がないケースもありません。

属性値の JavaScript コード

[48] イベントハンドラー内容属性属性値は、 JavaScript のコードであって、 自動セミコロン挿入を経て FunctionBody 生成規則に一致するようなものでなければなりません >>35

[49] つまり、 JavaScript関数の括弧の中身として書けるものでなければなりません。

[146] 構文上の誤りが含まれる場合、最初のコンパイル時 (イベントdispatch された時か、イベントハンドラーIDL属性の値を取得した時) に誤りの報告があります。

[147] 実行時には、原則として、 event という名前の引数が1つ渡されます。 これはイベントオブジェクトです。

[152] scope chain は、近い順に (対象要素, フォーム所有子, 大域オブジェクト) となります。 つまり、関数内で宣言された変数では無いものが参照された時、まず要素メンバーと解釈します。 次に、要素の属するフォームメンバーと解釈します。どちらでもなければ、 大域変数と解釈します。

[231] 次の例では、 buttonclick すると、 「post」と表示されます。

<form method=post action=...>
  <button type=button onclick=" alert (method) ">???</button>
</form>

属性の設定

[112] イベントハンドラー内容属性属性設定された時、 そのイベントハンドラーイベントハンドラーについて、 次のようにします >>35

  1. [209] 結果を、属性要素と「script attribute」、 属性について、 Should element's inline behavior be blocked by Content Security Policy? を実行した結果に設定します。
  2. [210] 結果Blocked 以外なら、
    1. [216] 属性位置内部生未コンパイルハンドラーイベントハンドラーの値を設定します。
[161] つまり属性の設定時点で CSPイベントハンドラー内容属性が無効化されていれば、 何も起こりません。

[212] 位置について、 HTML Standard属性を設定したスクリプトの位置と規定しています >>35構文解析器によって属性が設定された場合にどうするべきなのかは不明です。

属性の削除

[160] イベントハンドラー内容属性削除された時、 そのイベントハンドラーイベントハンドラーについて、 次のようにします >>35

  1. [217] nullイベントハンドラーの値を設定します。

XXX

[207] イベントハンドラーIDL属性設定時点でイベントハンドラーイベント対象が存在せず、その後節点の挿入が発生した場合、...
[208] イベントハンドラーIDL属性設定後にイベントハンドラーイベント対象が存在しなくなった (節点の削除があった) 場合、 ...

[38] イベントハンドラーの値は、

... のいずれかです。初期値は null です。 >>35 イベントハンドラーIDL属性により、 またはイベントハンドラー内容属性により、null 以外の値に設定することができます。

[131] 内部生未コンパイルハンドラー (internal raw uncompiled handler) は、 コンパイル前のスクリプト本体と、エラー報告の際に用いられるスクリプトの位置情報の組です。 >>35 これは実質的にはイベントハンドラー内容属性属性値のことを言っています。 後述の通りイベントハンドラー内容属性は設定されただけではコンパイルされず、 実行時にコンパイルされることになります。 (コンパイル結果である Function とは異なります。)

[213] 新しい値イベントハンドラーの値を設定するには、次のようにします >>35

  1. [211] イベントハンドラーオブジェクトが存在する場合 (>>41)、
    1. [202] イベントハンドラーオブジェクトイベントハンドラーを、 新しい値に設定します。
    2. [221] イベントハンドラー非null設定済みの場合、
      1. [64] イベントハンドラーオブジェクトイベントリスナー群の末尾に、 新しいイベントリスナーを追加します。
        [223] イベントリスナー
        イベント型
        イベントハンドラーイベント型
        コールバック
        [114] EventListener (関数)
        引数
        (引数)
        処理
        1. [224] イベントハンドラー引数についてイベントハンドラー処理アルゴリズムを実行します。
        コールバック文脈
        任意の値
      2. [222] イベントハンドラー非null設定済みを、に設定します。
    3. [128] イベントハンドラー初回設定済みで、 イベントハンドラーオブジェクトMessagePort で、 イベントハンドラーイベント型message の場合、
      1. [218] イベントハンドラーオブジェクトポートメッセージキューの状態無効なら、
        1. [219] イベントハンドラーオブジェクトポートメッセージキューの有効化を実行します。 >>214
      2. [220] イベントハンドラー初回設定済みを、に設定します。
    4. [82] イベントハンドラー初回設定済みで、 イベントハンドラーオブジェクトServiceWorkerContainer で、 イベントハンドラーイベント型message の場合、
      1. [122] イベントハンドラーオブジェクトクライアントメッセージキューの状態無効なら、
        1. [238] イベントハンドラーオブジェクトクライアントメッセージキューの有効化を実行します。 >>70
      2. [239] イベントハンドラー初回設定済みを、に設定します。
[65] イベントハンドラーnull に設定されている間は、 イベントリスナーは追加されません。また null に変更されたり、別の非 null 値に変更されたりしても、 イベントリスナーは登録されたままになります。 これはイベントリスナー間の実行順序に影響することになります。
[66] イベントハンドラーイベントリスナーイベントハンドラー処理算法は別のものとなります。 イベントハンドラーから arguments.callee でアクセスできるのはイベントハンドラーです。イベントリスナーイベントハンドラー処理算法JavaScript からアクセスする方法はありません。イベントハンドラーremoveEventListener しても、それ自体はイベントリスナーとして登録されていないので、削除できません。

[88] MessagePortServiceWorkerContaineronmessage は最初に設定された時にポートメッセージキュークライアントメッセージキューが有効になる (start メソッドstartMessages メソッドが呼ばれたかのように振る舞う) という副作用があります。

[107] addEventListener によって message に登録してもこのような副作用はありません。

イベントハンドラーの現在値

[132] イベントハンドラーの現在値を取得 (getting the current value of the event handler) は、 次のようにしなければなりません >>35

  1. [115] イベントハンドラー内部生未コンパイルハンドラーの場合、
    1. [116] イベントハンドラーオブジェクト要素の場合、
      1. [139] 要素を、イベントハンドラーオブジェクトに設定します。
      2. [225] 文書を、要素節点文書に設定します。
    2. [226] それ以外の場合、
      1. [227] 要素を、 null に設定します。
      2. [228] 文書を、 イベントハンドラーオブジェクト文書に設定します。
    3. [172] 設定群を、文書関連設定群オブジェクトに設定します。
    4. [263] realm を、 設定群Realm に設定します。
    5. [264] 適用範囲を、 realmGlobalEnv に設定します。
    6. [236] 要素null 以外の場合、
      1. [141] 適用範囲を、NewObjectEnvironment(文書, 適用範囲) の結果に設定します。
    7. [229] 文書スクリプトが無効の場合、
      1. [230] null を返し、ここで停止します。
    8. [232] 要素null 以外の場合、
      1. [234] 要素フォーム所有子null 以外の場合、
        1. [237] 適用範囲を、NewObjectEnvironment(要素フォーム所有子, 適用範囲) の結果に設定します。
      2. [233] 適用範囲を、NewObjectEnvironment(要素, 適用範囲) の結果に設定します。
    9. [135] 結果を、イベントハンドラーFunctionBody として構文解析した結果に設定します。
    10. [140] 結果構文解析不能または early error の場合、
      1. [180] イベントハンドラーを、 null に設定します。
      2. [176] 結果を、 結果イベントハンドラー位置設定群大域オブジェクトについて誤りを報告した結果に設定します。
      3. [177] 結果が「not handled」の場合、
        1. [178] 開発者コンソール誤りを報告して構いません
      4. [179] null を返し、ここで停止します。
    11. [181] JavaScript実行文脈スタックに、設定群realm実行文脈push します。
    12. [182] 関数を、 FuncrionCreate の結果に設定します。
      kind
      通常 (Normal)
      [142] ParameterList
      イベントハンドラーオブジェクトWindow で、イベントハンドラーイベント型error の場合
      (event, source, lineno, colno, error)
      それ以外の場合
      (event)
      [144] Body
      結果
      [145] Scope
      適用範囲
    13. [143] JavaScript実行文脈スタックから、設定群realm実行文脈を削除します。
    14. [258] 関数ScriptOrModule を、 null に設定します。
    15. [183] イベントハンドラーを、 関数に設定します。
  2. [133] イベントハンドラーを返します。
[134] イベントハンドラーの現在値を取得する操作は、 イベントハンドラーオブジェクト要素または Window の場合にのみ呼ばれます。 イベントハンドラーオブジェクトnull の場合には、呼ばれません。

イベントハンドラー処理アルゴリズム

[117] イベントハンドラー処理アルゴリズム (the event handler processing algorithm) は、 イベントハンドラーを呼び出すというイベントリスナーです。

イベントハンドラーイベントハンドラーイベントオブジェクトイベントについて、 次のようにします >>35

  1. [118] コールバックを、イベントハンドラーの現在値を取得した結果に設定します。
  2. [119] コールバックnull でなければ、
    1. [189] イベントerror で、 イベントインターフェイスErrorEvent で、 イベント現在対象WindowOrWorkerGlobalScope の場合、
      1. [125] 引数を、 (イベントメッセージ, イベントファイル名, イベント行番号, イベント列番号, イベント誤り) に設定します。
    2. [190] それ以外の場合、
      1. [188] 引数を、 (イベント) に設定します。
    3. [120] 返り値を、コールバックについてコールバック関数を呼び出した結果に設定します。
      コールバックthis
      イベント現在対象
      引数
      引数
      例外投げられたら、再び投げ、ここで停止します。
    4. [124] イベントerror で、 イベントインターフェイスErrorEvent で、 イベント現在対象WindowOrWorkerGlobalScope の場合、
      1. [126] 返り値なら、
        1. [127] イベント取り消しフラグを設定します。
    5. [193] それ以外で、イベントbeforeunload で、 イベントインターフェイスBeforeUnloadEvent の場合、
      1. [194] 返り値null 以外なら、
        1. [195] イベント取り消しフラグを設定します。
        2. [196] イベントreturnValue空文字列なら、
          1. [197] イベントreturnValue を、返り値に設定します。
    6. [187] それ以外の場合、
      1. [191] 返り値なら、
        1. [192] イベント取り消しフラグを設定します。

[198]アルゴリズムは、イベントハンドラーが最初に設定されたときにイベントリスナーとして登録されます。 それ以外では使われません。登録済みのイベントリスナースクリプトから取得する方法は用意されていませんから、 本アルゴリズムに相当する JavaScript 関数オブジェクトスクリプトからアクセスする方法もありません。

[74] コールバックthisの規定と、 bodyonloadWindow オブジェクトイベントハンドラーであることから、

<body onload="alert(this)" onclick="alert(this)">
... は文書の読み込み時に "[object Window]" が、クリック時に "[object HTMLBodyElement]">>35 alert されることとなります。

特別なイベントハンドラーの一覧

イベントハンドラーの一覧

[8] この種の属性のリストは事象取扱器属性の一覧を参照してください。

イベントハンドラーとイベントリスナー

[69] イベントハンドラーは、 addEventListener で登録される一般のイベントリスナーと違って、 次のような制限があります。

[81] こういった制限もありますが、簡潔に記述でき多くの用途には十分でもあるので、 イベントハンドラーもよく使われています。

歴史

誕生

[84] イベントハンドラーは、当初から JavaScript の機能として存在していました。

[85] W3C DOM には含まれていないため、00年代には DOM0 の一部とされていました。
[101] 現在はイベントリスナーの特殊形とされていますが、当時はまだイベントリスナーはありませんでした。 イベントリスナーIE4 DOM で追加されました。

スクリプト言語の指定

  • [1] HTML の on* 属性 (非推奨。) で JavaScript を使う時に、先頭に javascript: って書く DQN がなぜか多いな。
  • [2] >>1 まあ Content-Script-Type: 問題についての不思議マーク付け的解法なのかもしれんが。。。(w
  • [3] >>1-2 にしても、文法エラーにならずに動く (こともある。) なんて、一体どうなっているんだ? JavaScript 的にはどういう扱いになってるんだろう? それとも UA の補正なのかな?
  • [4] >>3 ラベル

[5] >>1-4 WinIE だとそれが“ちゃんと”はたらいて、 vbscript: と書くと VBScript になったりしちゃいます。

[10]

748 名前:Name_Not_Found[sage] 投稿日:2005/10/08(土) 04:12:41 ID:???

 HTML のイベント属性に javascript: を書くことについて。
 - 文法的には、ただのラベルである。
 - そこそこ誰でも知っていて、なんとなく使ったり読んだりしている。
 - WinIE が、javascript, jscript, vbscript, vbs, perlscript に反応する。
 &#160;&#160;(プラットフォームも含め、過不足あれば指摘してくれ。)
 - しかし、きちんとした仕様説明が見当たらない (探せなかっただけかもしれないが)。
 ラベル
 ttp://www2u.biglobe.ne.jp/~oz-07ams/prog/ecma262r3/12_Statements.html#LabelledStatement
 &#160;&#160;FOO: for ( .. ) for ( .. ) if ( .. ) continue FOO;
 におけるラベル FOO と同じ。
 ラベルの例をもう一つ。
 &#160;&#160;<p onclick="rubyscript:while (true)
 &#160;&#160;&#160;&#160;for (var i = 0; i < 10; i++)
 &#160;&#160;&#160;&#160;if (i == 6) break rubyscript;
 &#160;&#160;&#160;&#160;alert(i);">alert(6)</p>
 どうやら、良く練られた拡張ではなく、姑息な特例だと言わざるを得ない。
 
;;
+ JavaScript の質問用スレッド vol.41 +
http://pc8.2ch.net/test/read.cgi/hp/1127133050/

内部での表現

[9] Hawk's W3 Laboratory : DHTML Tips : イベントハンドラに関する考察 http://www.hawk.34sp.com/stdpls/dhtml/event-handler.html http://web.archive.org/web/20061021223123/www.hawk.34sp.com/stdpls/dhtml/event-handler.html

更新日時
2004年09月22日

結論から言うと、この「属性の中身のコード」は、対象となる要素に対応するHTMLElementオブジェクトのプロパティに、関数の形で格納されています。イベント発生時にはそのオブジェクトのメソッドとして実行されるわけです。

実体が関数であることは、イベント内でargumentsを参照できることから分かります。更に一歩進んでarguments.calleeにアクセスすれば実体の関数そのものにアクセスできます。

以下の例では関数の内容を表示しています。alert(arguments.callee);という記述が "そのまま"表示されるのが確認できるでしょう。

<a href="http://hawk.34sp.com/" onmouseover="alert(arguments.callee);">リンク</a>

ただし、実際に試してみれば分かりますが、表示内容(すなわち実装方法)はブラウザによって大きく2系統に分かれます。上記の例はIEでは以下のように表示されるはずです。

function anonymous()
{
alert(arguments.callee);
}

anonymous(匿名)とは無名のFunctionオブジェクトに仮に付けられた名です。つまりIEでは、単に属性値のスクリプトコードを実行するだけの関数が生成され、対象となるオブジェクトのプロパティに格納されることになります。

一方で、NN4.XおよびGeckoベースのブラウザでは以下のようになります。

function onmouseover(event)
{
alert(arguments.callee);
}

Operaではこうです。

function anonymous(event)
{
alert(arguments.callee);
}

KHTMLベースのブラウザではこうなります。

function (event)
{
alert(arguments.callee);
}

名前の有無や名前が無い場合の表現など、瑣末な違いはありますが、いずれもeventという仮引数が存在していることが大きな特徴です。この仮引数はイベントオブジェクト(NN4.Xにおいてはevent object、その他の場合はDOM2 EventsにおけるEventインターフェイスを実装したオブジェクト)を表しています。

NN4.Xのイベントモデルでも、DOM2 Eventsでも、イベントに関する情報はイベントオブジェクトの形で、イベントハンドラとして登録された関数の第一引数に渡されます。だからこのような形の関数になるのは理にかなっているのですが、そのとき仮引数の名前が”event”になることなどは特に標準化されていないので注意が必要です。

またこのeventという名前は、偶然にも?IEのwindow.eventと同じなので、

<a href="http://hawk.34sp.com/" onmouseover="foo(event);">リンク</a>

このように記述すれば、関数fooにはブラウザを問わず第一引数にeventオブジェクトが渡されます(もっともfoo内での条件分岐は必要になりますが)。

[11] 関数内で関数名を使って再起呼び出しできるのかな?

window.event

[6] WinIE7, Opera, WebKit は対応しているみたいです。

[7] Firefox3 は対応していないみたいです。

[12] 事象取扱器属性の時だけでなく、 attachEvent した事象取扱器の時にも設定されているの?

[137] Bug 111602 – Remove window.event ( ( 版)) https://bugs.webkit.org/show_bug.cgi?id=111602

[138] window.event and Event.srcElement ( (Anne van Kesteren 著, 版)) http://lists.w3.org/Archives/Public/public-webapps/2013JanMar/0961.html

HTML4

[151] XHTML m12n では XHTML Events Module が定義されており、 現在のイベントハンドラー内容属性が含まれていました。

[269] CEA-2014-B

忌避

[63] イベントハンドラー内容属性HTML4 には一般的なものが含まれたものの、 DOM Events が標準化された後も改めて厳密に定義され直すことはなく、 Webブラウザーの実装は長らく明文化されないままでした。 イベントハンドラーIDL属性Web Applications 1.0 まで言及もされていませんでした。

[67] そのため表示方法を記述する物理属性と同様に避けるべきだと主張する人達も00年代には少なくありませんでした。 当時の HTML WG も、イベントハンドラー内容属性にかわって XHTML Events 改め XML Events を開発し、それによって置き換えることを狙っていたようです。

[68] しかしイベントハンドラーが簡潔で便利でしたし、 W3C DOMaddEventListenerIE4 DOMattachEvent に分裂していたこの時代、 XML Events も含めどの方法も他の方法を完全に置き換える程の勢力は得られませんでした。

HTML Standard

[13] (X)HTML5 Tracking ( 版) http://html5.org/tools/web-apps-tracker?from=4049&to=4050

[14] [whatwg] Additional onxxxx event attributes for DOM Level3 Events ( 版) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-November/029252.html

[15] Web Applications 1.0 r5933 Be better about how we define the creation of scripts for event handler attributes (specifically, how we interact with the JS spec). ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5932&to=5933

[16] [whatwg] on* attributes on DOM elements ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-June/032146.html

[17] IRC logs: freenode / #whatwg / 20110728 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20110728#l-242

[18] IRC logs: freenode / #whatwg / 20111117 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20111117

[19] [whatwg] API design restrictions due to barewords in onxxx="" attributes ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-November/033959.html

[20] Writing forward-compatible websites - MDN ( ( 版)) https://developer.mozilla.org/Writing_Forward_Compatible_Websites

[21] IRC logs: freenode / #whatwg / 20120427 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20120427#l-633

[22] IRC logs: freenode / #whatwg / 20120518 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20120518

[23] [proximity] HTML's WebIDL Function ( (Marcos Caceres 著, 版)) http://lists.w3.org/Archives/Public/public-device-apis/2012May/0283.html

[24] IRC logs: freenode / #whatwg / 20120620 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20120620#l-321

[25] Web Applications 1.0 r7235 Improve compatibiliy for legacy features. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7234&to=7235

[26] [whatwg] Specification unclear about how HTMLElement.prototype.onscroll's getter/setter should behave for "body" elements ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-December/038221.html

[27] Web Applications 1.0 r7560 Remove some IDL shadowing. See also bug 20225. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7559&to=7560

[28] Web Applications 1.0 r7561 Recent changes to body also apply to frameset. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7560&to=7561

[29] WICD Mobile 1.0 ( ( 版)) http://www.w3.org/TR/WICDMobile/#XHTML-event-attributes

[30] [whatwg] Specification unclear about how HTMLElement.prototype.onscroll's getter/setter should behave for "body" elements ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-January/038528.html

[31] Web Applications 1.0 r7638 Factor out some common event handler declarations in IDL. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7637&to=7638

[32] Web Applications 1.0 r7667 Clean up how we define event handlers that are shadowed for Window on <body>. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7666&to=7667

[33] Web Applications 1.0 r7668 Fix bug 18626 and actually do what the previous checkin was trying to do. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7667&to=7668

[86] Web Applications 1.0 r7933 Bring onbeforeunload handling closer to compatibility with the Web ( 版) http://html5.org/tools/web-apps-tracker?from=7932&to=7933

[87] Bug 20637 – Remove onfullscreen* from HTML ( ( 版)) https://www.w3.org/Bugs/Public/show_bug.cgi?id=20637

[89] Web Applications 1.0 r8097 Add more cross references to the new 'concept-window-document' thing, and clean up <frameset>'s event definitions (I always forget to update that when I'm updating <body>'s...). ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8096&to=8097

[90] Web Applications 1.0 r2529 MAJOR CHANGES: Revamp the way scripts are specified, along with their interaction with resolving relative URLs, etc. Give enough detail to justify objects in the DOM not being garbage collected randomly when still in use. Define script groups, to handle scripts going away during document.open() and session history navigation. Define why and how setTimeout(), database transactions, etc, handle page transitions. Drop the terms 'with' and 'without' script, use script is 'enabled'/'disabled' instead. Define 'unload' and 'beforeunload'. Rework how onfoo= and .onfoo event handler attributes are defined. Rework how the content model of <noscript> is defined. Reword the way javascript: is defined to use the new terminology. Add a few notes of things that came up while I was doing all that.]] ( ( 版)) http://html5.org/tools/web-apps-tracker?from=2528&to=2529

[91] [whatwg] Should onfoo event handler properties be on Element or HTMLElement? ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-October/040992.html

[92] Web Applications 1.0 r8303 Move the event handler content attribute compiling logic to later in the pipeline, for better consistency with Firefox/Safari (and other browsers, though to a lesser extent). ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8302&to=8303

[93] Web Applications 1.0 r8282 OnBeforeUnloadEventHandler is supposed to allow null return values (and some markup error fixes, oops) ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8281&to=8282

[94] XML Binding Language (XBL) 2.0 ( ( 版)) http://www.w3.org/TR/2007/CR-xbl-20070316/#event0

[95] Web Applications 1.0 r8375 Rearrange requirements for handling internal raw uncompiled handlers ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8374&to=8375

[149] >>96 によって改訂されるまでは、イベントハンドラー内容属性は設定時にコンパイルが行われるようになっていました。

[50] スクリプトが有効閲覧文脈にある Document が所有する要素イベント・ハンドラー内容属性が設定された時、次のように処理しなければなりません >>35

[51] そのような文書adopt された時も同様と思われます。
  1. [52] 対応するイベント・ハンドラーnull に設定します。
  2. [53] JavaScriptスクリプト実行環境を準備します。
  3. [54] bodyイベント・ハンドラー内容属性の新しい値とします。
  4. [55] bodyFunctionBody として構文解析可能でないか、 構文解析によって early error を検出した場合は、イベント・ハンドラー内容属性を誤りに設定し、 停止します。
  5. [56] bodyUse Strict Directive を含む Directive Prologue ("use strict") から始まるかどうかを strict とします。
  6. [57] >>53スクリプト実行環境を使って次のような関数オブジェクトを作り、 スクリプトlist of code entry-points に入れます。
  7. [58] スクリプトの大域オブジェクトスクリプトの閲覧文脈スクリプトの文書スクリプトの参照元情報源スクリプトのURL文字符号化スクリプトの基底URLを当該要素による節点からスクリプト設定の決定により設定します。
  8. [59] 対応するイベント・ハンドラー>>57関数とします。

[60] イベント・ハンドラー内容属性を誤りに設定 (set the event handler content attribute to an error) するとは、対応するイベント・ハンドラー内部誤り値 (internal error value) に設定することをいいます。 内部誤り値誤り条件 (error condition) を表現するもので、 イベント・ハンドラー内容属性が設定された資源URL行番号を記録するものです。 >>35

再定義

[150] >>96 によってイベントハンドラー内容属性のコンパイルは初めて呼び出された時まで遅延されるようになりました。

[154] Re: Spec for [Global] does not seem to be quite web-compatible, and none of the UAs are really compatible with each other ( (Boris Zbarsky 著, 版)) http://lists.w3.org/Archives/Public/public-script-coord/2013OctDec/0416.html

[155] The "initialization" steps for Web browsers ( ( 版)) https://mail.mozilla.org/pipermail/es-discuss/2014-July/038426.html

[156] svg2: changeset 698:568ea4166630 ( ( 版)) https://dvcs.w3.org/hg/svg2/rev/568ea4166630b31bb0e5c7024493f127e4aa664f

[157] 911477 – Implement DOM4 methods: prepend(), append(), before(), after() and replace() ( ( 版)) https://bugzilla.mozilla.org/show_bug.cgi?id=911477

[158] Add on* attributes · e793402 · whatwg/notifications ( ( 版)) https://github.com/whatwg/notifications/commit/e793402a13e125a865f5a6a053d4cfd03c242193

[102] Web Applications 1.0 r8880 Fix callback logic to reference Web IDL and use the right conventions. ( 版) https://html5.org/r/8880

[103] Pointer Events ( 版) https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#h-extensions-to-the-element-interface

[104] Pointer Events ( 版) https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#h-extensions-to-the-element-interface

[110] Bug 20713 – Consider defining window.event and Event.srcElement ( 版) https://www.w3.org/Bugs/Public/show_bug.cgi?id=20713

[111] Define the ontouch* event handler attributes · Issue #11 · w3c/touch-events ( 版) https://github.com/w3c/touch-events/issues/11

[113] Clarify some wording around event handlers · whatwg/html@434cbda ( 版) https://github.com/whatwg/html/commit/434cbda5377f6ce3debbeb05104ba94a0eee75da

[121] Update ECMAScript and IDL integration · whatwg/html@550c57f ( 版) https://github.com/whatwg/html/commit/550c57f186dd73784a8e4660440db2f642e37c0e

[123] Revert "Update ECMAScript and IDL integration" · whatwg/html@3a23548 ( 版) https://github.com/whatwg/html/commit/3a235480f1979fcddc65e07fe5a3be7bed428d17

[159] Close #384: add CSP hooks to handle inline events and style · whatwg/html@920c918 ( 版) https://github.com/whatwg/html/commit/920c9183a7990968ecac1aeedae22391f3438791

[162] Update ECMAScript and IDL integration · whatwg/html@52f96c4 ( 版) https://github.com/whatwg/html/commit/52f96c455a53763a7fe00162c067da6adb20e62c

[163] Rewrite script execution on top of ES · whatwg/html@4891d18 ( 版) https://github.com/whatwg/html/commit/4891d18aaf2df1d40aa61f467a5a10cfc19dd85d

[164] + JavaScript の質問用スレッド vol.67 + ( 版) http://pc11.2ch.net/test/read.cgi/hp/1223618153/474

IE6とOpera9では動いたのですが

FireFox3.0.4でうまく動きません

何か間違ってるのでしょうか?

<form method="post">

<a href="" onclick="submit(); return false;">hoge</a>

</form>

[165] Report errors to developer consoles, not users · whatwg/html@a6d04ea ( 版) https://github.com/whatwg/html/commit/a6d04ea7652f5ad1b61e4ab95de490f51511bffe

[136] Add <script type="module"> and module resolution/fetching/evaluation · whatwg/html@cd1a9fb ( 版) https://github.com/whatwg/html/commit/cd1a9fb1e83f7d0bc30be8b34ecdaf444a0b19a4

[166] Adding event handler attributes cut/copy/paste · whatwg/html@efe130a ( 版) https://github.com/whatwg/html/commit/efe130a0566a43067659c1d92bf712b151db0727

[167] Remove capture from event handler attributes as it is false by default · whatwg/html@096661f ( 版) https://github.com/whatwg/html/commit/096661f04d071933a79533089d82c316eff6509a

[168] Clarify settings object, realm, and global relationships · whatwg/html@0866f1b ( 版) https://github.com/whatwg/html/commit/0866f1b3f4b4ea5a99a30909e9bbe557dea0b460

[169] Add the 'unsafe-hash-attributes' source expression. · w3c/webappsec-csp@a2bb43f ( 版) https://github.com/w3c/webappsec-csp/commit/a2bb43f407949a860f027a97e232c755b51029ab

[170] Add a source argument to CSP's inline behavior algorithm · whatwg/html@e0863d9 ( 版) https://github.com/whatwg/html/commit/e0863d93ec8c0b48f1c44d8d81a409eb08dee28c

[171] Event handlers should return null if scripting is disabled · whatwg/html@0d634e4 ( 版) https://github.com/whatwg/html/commit/0d634e41ff1ab0684e0b9faa2cb7461e0db3b8a1

[173] Be more precise about nested and discarded browsing contexts (domenic著, ) https://github.com/whatwg/html/commit/39118df640ad4a3f03f164fb5ffe0a56316297be

[174] Spec for getter of event handler attribute has some nonsense about exceptions · Issue #1957 · whatwg/html () https://github.com/whatwg/html/issues/1957

[175] Set the Realm when compiling event handler IDL attributes (domenic著, ) https://github.com/whatwg/html/commit/09a8c470b84108a42c0920c2e968a1d7c20a6edd

[185] (X)HTML5 Tracking ( 版) http://html5.org/tools/web-apps-tracker?from=4012&to=4013

[186] Fix onbeforeunload event handler processing (domenic著, ) https://github.com/whatwg/html/commit/fb7e621eab8a437df7ac524e547e31e117b7fce5

[199] Fix event callback invocation to set entry/incumbent correctly (domenic著, ) https://github.com/whatwg/html/commit/037f35d4a114d5543d5caa17689cbe1b095790cf

[235] Fix event handler processing algorithm special cases (domenic著, ) https://github.com/whatwg/html/commit/c065e991b65e10a1fc77ba77fed9f0822ff6858b

[240] Meta: export event handler <dfn>s (tobie著, ) https://github.com/whatwg/html/commit/d0154579f6237358a7a642ae59b894e9116c4fbd

[241] Meta: export event handler DFNs. by tobie · Pull Request #2936 · whatwg/html () https://github.com/whatwg/html/pull/2936

[242] Move EventHandler to DOM spec · Issue #509 · whatwg/dom () https://github.com/whatwg/dom/issues/509

[243] Editorial: Cut dev-edition event-handler “must”s (sideshowbarker著, ) https://github.com/whatwg/html/commit/d4d1178845e17721b21ff6fd242b0be78a3de9a0

[244] Editorial: Cut event-handler “must”s in dev edition by sideshowbarker · Pull Request #3170 · whatwg/html () https://github.com/whatwg/html/pull/3170

[245] DOM handler and import · Issue #32 · tc39/proposal-dynamic-import () https://github.com/tc39/proposal-dynamic-import/issues/32

[246] AMP HTML Specification – AMP () https://www.ampproject.org/docs/reference/spec

Attribute names starting with on (such as onclick or onmouseover) are disallowed in AMP HTML. The attribute with the literal name on (no suffix) is allowed.

[247] Editorial: add "add an event listener" hook (annevk著, ) https://github.com/whatwg/dom/commit/2bdabb15de8112d9783cf393a3d6c37911149f77

[248] Editorial: add "add an event listener" hook by annevk · Pull Request #596 · whatwg/dom () https://github.com/whatwg/dom/pull/596

[249] Make event handlers share a code path with addEventListener() (annevk著, ) https://github.com/whatwg/html/commit/9a2a66cd8f8ddfa4c35d784bcda5c080e82aad38

[250] Make event handlers share a code path with addEventListener() by annevk · Pull Request #3561 · whatwg/html () https://github.com/whatwg/html/pull/3561

[251] Standardize window.event (miketaylr著, ) https://github.com/whatwg/dom/commit/c69d7c0fb8796de884652c517825122d12901ef5

[252] Standardize srcElement, returnValue, and window.event · Issue #334 · whatwg/dom () https://github.com/whatwg/dom/issues/334

[253] Add window.event as a legacy compat requirement by miketaylr · Pull Request #407 · whatwg/dom () https://github.com/whatwg/dom/pull/407

[254] Revise event listener removal in document.open() (TimothyGu著, ) https://github.com/whatwg/html/commit/823f4bcb5a4d80b231c81503dbc7c71c209617e5

[255] Revise event listener removal in document.open() by TimothyGu · Pull Request #3893 · whatwg/html () https://github.com/whatwg/html/pull/3893

[256] Event-based form participation (tkent-google著, ) https://github.com/whatwg/html/commit/1375c0ca5dd95ecb2ae5ad1d8d7bcc9bc75981c0

[257] Always set [[ScriptOrModule]] to null for event handler functions (domenic著, ) https://github.com/whatwg/html/commit/1d6eb9933701ea65f7a9dd670d37a2faa17b8f12

[259] import() behaviour in event handlers is path dependent · Issue #4267 · whatwg/html () https://github.com/whatwg/html/issues/4267

[260] Handle module resolution when there is no active script by domenic · Pull Request #4181 · whatwg/html () https://github.com/whatwg/html/pull/4181

[261] Always set [[ScriptOrModule]] to null for event handler functions by domenic · Pull Request #4302 · whatwg/html () https://github.com/whatwg/html/pull/4302

[262] Add onslotchange · Issue #3487 · whatwg/html () https://github.com/whatwg/html/issues/3487

[265] Use [[GlobalEnv]] in event handler's current value (shvaikalesh著, ) https://github.com/whatwg/html/commit/e51cf93ad10e91d82f69a037928ae6b09969907d

[266] Event handler FunctionCreate uses an undefined variable "global environment" · Issue #2467 · whatwg/html () https://github.com/whatwg/html/issues/2467

[267] Editorial: use [[GlobalEnv]] in event handler's current value by shvaikalesh · Pull Request #4756 · whatwg/html () https://github.com/whatwg/html/pull/4756

[268] Editorial: Remove 'Strict' arg from FunctionCreate call (jmdyck著, ) https://github.com/whatwg/html/commit/39dd2044f5371cabf4bd9cbb1c24b5a3a08c4166

[148] Editorial: Remove 'Strict' arg from FunctionCreate call by jmdyck · Pull Request #4712 · whatwg/html () https://github.com/whatwg/html/pull/4712