loading

Document インターフェイス readyState 属性 (DOM)

[7] Document オブジェクトreadyState 属性は、 現在文書準備度を表します。

仕様書

取得器

[12] document.readyState 属性文書現在文書準備度を返さなければなりません >>10

現在文書準備度

[9] 文書は「現在文書準備度 (current document readiness) 」という状態を持っています >>11

[6] 構文解析XSLT の処理を行う場合、現在文書準備度は、 loadinginteractivecomplete と変化します。そうでない場合は、 最初から complete となります。

[24] この3つの値は、 Web IDLenum である DocumentReadyState です。

[23] document.opendocument.load では、現在文書準備度loading に戻ります。

[25] 詳しくは、次のように変化します。

[15] 現在文書準備度が設定された時には、その Document オブジェクトにおいて readystatechange 単純事象を発火しなければなりません >>11

[19] 現在文書準備度履歴探索の過程で pageshow 事象popstate 事象発火されるかに影響します。

歴史

[2] Dynamic HTML(クライアントサイドスクリプトやIE固有のプログラム要素も含む) ( 版) <http://www.rody.dev-asp.net/memo/dhtml/index.html>

絶対にそうだとは言えないが、調べたところでは以下のような関係だった。

  1. 子ウィンドウを持つウィンドウは全ての子ウィンドウのreadyStateが"complete"にならないと、自ウィンドウのreadyStateは"complete"にならない。また、正確にはreadyStateが"complete"でdocument.onReadyStateChangeイベントを抜けた時に、完全に"complete"したとみなす。
  2. window.onloadイベントは自ウィンドウのreadyStateが"complete"になった後、発生する(正確な判断は1と同様)。
  3. 兄弟ウィンドウ同士は非同期で動作する。
  4. (重要)1及び2からウィンドウが"complete"する順番は子ウィンドウから正しく"complete"する事になるが、各ウィンドウのonloadイベントに関しては必ずしも同期しているとは限らない。親ウィンドウのonloadが子ウィンドウのonloadよりも先に走る可能性もタイミングによっては有り得る。
  5. 他のファイルをインクルードしているものに関しては分からないが、 readyStateが"complete"になるのはhtmlタグ内のドキュメントが読み込み終わった時ではなくて、そのファイル全体のソースが読み込み終わった時に発生しているっぽい(どっちにしろhtmlタグ内に全て書いていれば関係ないが)。

補足:もし、子ウィンドウのロードを非同期で(同時に)行い、各ウィンドウの初期処理を正確に順番通りに行いたいためにトップウィンドウのonReadyStateChangeイベント、もしくはonloadイベントで子ウィンドウの初期処理を順番に行うのであれば、子ウィンドウのonReadyStateChangeイベントもしくはonloadイベントに初期処理を入れるべきではない。トップウィンドウからの初期処理関数呼び出しと、各子ウィンドウのonloadイベントに初期処理が記述されている場合、どちらの初期処理が先に走るかは不定。よって、もう片方の初期処理が完了している事を前提でコーディングすると、処理が走るタイミングによっては未初期化でエラーが発生するかも。

[4] document.readyState - 素人がプログラミングを勉強するブログ ( 版) <http://d.hatena.ne.jp/javascripter/20090125/1232880728>

[37] Web Applications 1.0 r5501 document.readyState should be updated after csalling document.open(). ( ( 版)) <http://html5.org/tools/web-apps-tracker?from=5500&to=5501>

[43] HTML5 Tracker ( 版) <http://html5.org/tools/web-apps-tracker?from=6688&to=6689>

[44] Web Applications 1.0 r6882 Make the readyState change, the 'readystatechange' event, and the 'load' event all happen synchronously in the same task so that you can check readyState to know whether you still have to attach an 'onload' event handler. ( ( 版)) <http://html5.org/tools/web-apps-tracker?from=6881&to=6882>

[45] [whatwg] Readiness of script-created documents ( ( 版)) <http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-January/034363.html>

[46] IRC logs: freenode / #whatwg / 20120313 ( ( 版)) <http://krijnhoetmer.nl/irc-logs/whatwg/20120313>

[47] [whatwg] Readiness of script-created documents ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-June/036356.html>

[48] Web Applications 1.0 r7169 Make 'abort the parser' fire some readystatechange events for more consistency. Slightly expand on how little XSLT/HTML interactions are defined. Rename 'cookie-free' to 'cookie-averse' for clarity. ( ( 版)) <http://html5.org/tools/web-apps-tracker?from=7168&to=7169>

[49] [whatwg] Proposal for readyState behavior ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-July/036592.html>

[50] [whatwg] DOMContentLoaded, load and current document readiness ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-August/037045.html>

[51] [whatwg] Proposal for readyState behavior ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-August/037042.html>

[52] [whatwg] Readiness of script-created documents ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-August/037040.html>

[53] Web Applications 1.0 r7299 Try to make aborting parsing and regular ending of parsing slightly more similar. Also, emphasise the importance of stress in the definition of <em>. (Sorry for the mixed checkin.) ( ( 版)) <http://html5.org/tools/web-apps-tracker?from=7298&to=7299>

[54] Web Applications 1.0 r7781 Make document.readyState explicitly an enum, not that that has any real effect. ( ( 版)) <http://html5.org/tools/web-apps-tracker?from=7780&to=7781>