harumemo

メモ書きです。

「document.onreadystatechange」の実行タイミングはいつなのか?

 雑だけど以下のスクリプトで動作を確認。Firefox(39.0)だと、「interactive」に次いで「complete」のアラートが現れた。

 ブラウザによって動作が異なる模様。参考になりました:
document.readyState - 素人がプログラミングを勉強していたブログ

<script type="text/javascript"> // <![CDATA[
(function() {
	document.onreadystatechange = function() {
		if (this.readyState == 'uninitialized') { alert("uninitialized"); }
		if (this.readyState == 'loading')       { alert("loading"); }
		if (this.readyState == 'loaded')        { alert("loaded"); }
		if (this.readyState == 'interactive')   { alert("interactive"); }
		if (this.readyState == 'complete')      { alert("complete"); }
	}
})();
// ]]></script>