/
388.txt
195 lines (143 loc) · 9.13 KB
/
388.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
* 仕様書
[REFS[
- [22] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-04-25 04:40:19 +09:00]] 版) <https://html.spec.whatwg.org/#unloading-documents>
- [17] [CITE@en[Page Visibility]] ([TIME[2013-05-20 14:33:13 +09:00]] 版) <https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#pv-unloaded>
]REFS]
* 文書を unload
[24] [DFN[[RUBYB[文書の unload]@en[unload a document]]]]は、
次のようにしなければ[['''なりません''']]。
;; [25] [[引数]] [VAR[recycle]] は[[真]]または[[偽]]で、
[[文書]]を再利用するかどうかを表します [SRC[>>22]]。
[CODE(JS)@en[[[window.open]]]] で使います。
[FIG(steps)[
= [[文書]]の [[unload a document]] 呼び出し済みフラグを[[真]]に設定します。
([CODE(JS)@en[[[document.open]]]] で使います。)
= [[文書]]の[[イベントループ]]の [[termination nesting level]] を一度[[インクリメント]]します [SRC[>>22]]。
= [[文書]]の [[ignore-opens-during-unload counter]] を一度[[インクリメント]]します [SRC[>>22]]。
= [[文書]]の [[page showing]] フラグが[[真]]なら、
== [[文書]]の [[page showing]] フラグを[[偽]]に設定します [SRC[>>22]]。
== [[イベント]]を[[発火]]します [SRC[>>22]]。
[FIG(list members short)[
[FIGCAPTION[
[[イベント]]
]FIGCAPTION]
:[[インターフェイス]]:[CODE(DOMi)@en[[[PageTransitionEvent]]]]
:[[イベント型]]:[CODE(DOMe)@en[[[pagehide]]]]
:[[対象]]:[[文書]]の [CODE(DOMi)@en[[[Window]]]]
:[[target override]]:[[文書]]
:[[trusted]]:[[真]]
:[[bubbles]]:[[偽]]
:[[取り消し可能]]:[[偽]]
:[CODE(DOMa)@en[[[persisted]]]]:[[文書]]の [[''salvageable'']]
:[[既定動作]]:なし
]FIG]
== [[unloading document visibility change steps]] を実行します [SRC[>>22]]。
= [36] [[文書]]の [[fired unload]] フラグが[[偽]]なら、
== [35] [[単純イベントを発火]]します [SRC[>>22]]。
[FIG(list members middle)[
[FIGCAPTION[
[37] [[単純イベント]]
]FIGCAPTION]
:[[イベント型]]:[CODE(DOMe)@en[[[unload]]]]
:[[対象]]:[[文書]]の [CODE(DOMi)@en[[[Window]]]]
:[[target override]]:[[文書]]
]FIG]
= [38] [[文書]]の[[イベントループ]]の [[termination nesting level]] を一度[[デクリメント]]します [SRC[>>22]]。
= [39] 先の [CODE(DOMe)@en[[[unload]]]] [[イベント]]の[[発火]]で何らかの[[イベントリスナー]]が実行されていれば、
== [[文書]]の [[''salvageable'']] を[[偽]]に設定します [SRC[>>22]]。
== [[文書]]の [[fired unload]] フラグを[[真]]に設定します [SRC[>>22]]。
= [[unloading document cleanup steps]] を実行します [SRC[>>22]]。
= これが再帰呼び出しでないなら、
== [[文書]]の[[子孫閲覧文脈のリスト]]の各[[閲覧文脈]]について、
=== [[閲覧文脈]]の[[活性文書]]について [[unload a document]] を再帰的に呼び出します。
[VAR[recycle]] は[[偽]]とします。 [SRC[>>22]]
=== [[閲覧文脈]]の[[活性文書]]の [[''salvageable'']] が[[偽]]なら、
[[文書]]の [[''salvageable'']] も[[偽]]に設定します [SRC[>>22]]。
== [[文書]]の [[''salvageable'']] が[[偽]]で、 [VAR[recycle]] も[[偽]]なら、
[[文書]]の[[閲覧文脈]]により[[文書を捨てる]]処理を実行します [SRC[>>22]]。
= [[文書]]の [[ignore-opens-during-unload counter]] を一度[[デクリメント]]します [SRC[>>22]]。
]FIG]
[23] [[文書]]の [DFN[[[fired unload]]]] フラグの初期値は、[[偽]]です [SRC[>>22]]。
;; [[文書のunload]]でしか参照されません。
[26] [[unload a document]] の実行中か否かは、 [CODE(JS)@en[[[window.stop]]]]
の実行に影響します。
[31] ⊿ を指定した[[履歴の探索]]は、 [[unload a document]] を呼び出すことがあります。
[27] [[unload a document]] の実行中は、⊿ を指定した[[履歴の探索]]は行われません。
[28] [[unload a document]] の実行中は、 [[navigate]] は行われません。
[29] [[navigate]] は [[unload a document]] を呼び出すことがあります。
その呼び出し中に [[navigate]] が取り消されたとしても、 [[unload a document]]
の実行は中断されません。
;; [[navigate]] を参照。
[33] [[閲覧文脈を閉じる]]と、[[unload a document]] が呼び出されることがあります。
[30] [CODE(JS)@en[[[document.open]]]] は、 [[unload a document]] を呼び出すことがあります。
[32] [[unload a document]] を呼び出す場合は、それより前に [[prompt to unload a document]]
が呼び出されています。
* onunload 属性 (HTML, XHTML 1)
@@ この章は古いです
[1] [[HTML]] の [CODE(HTMLe)[[[body]]]] 要素と
[CODE(HTMLe)[[[frameset]]]] 要素の [DFN[[CODE(HTMLa)[onunload]] 属性]]は、
[[UA]] が[[窓]]または[[フレーム]]から[[文書]]を除去する時に発生する[[事象]]に関する[[内在事象]]属性です。
[2] 仕様書:
- [[HTML 4]]
-- [CODE(HTMLa)[onunload]] 属性
<IW:HTML4:"interact/scripts.html#adef-onunload">
[[#comment]]
** 代替
[3] 内在事象属性は[[表現と構造の分離]]の原則に反するので、
好ましくないと考える人もいます。また、 [[DOM 0]]
に基づく古い設計です。
代わりに、 [CODE(HTMLe)[[[script]]]] 要素などにより関連付けたスクリプト内で
[[DOM 2]] 以上の[[事象]]に関するメソッド等が利用できます。
DOM 水準2 や DOM 水準 3 の HTML 事象モジュールはこの属性に対応する
DOM の事象 [CODE(DOM)[[[unload]]]] を用意しています。
[[#comment]]
** 属性値
[4] この属性の値は [CODE(SGML)[%[[Script]]]] です。 [[SGML]]
的には [CODE(SGML)[[[CDATA]]]] です。[[スクリプト言語]]は、
[CODE(HTTP)[[[Content-Script-Type]]]] によります。
[5] この属性は省略可能です。
[[#comment]]
** 他との関係
[6] この属性に対応する DOM の事象は [CODE(DOM)[[[load]]]]
です。そちらもあわせてごらんください。
[7] 反対の意味の [CODE(HTMLa)[[[onload]]]] 属性もあります。
* 歴史
** [CODE(DOMa)@en[visibilityState]] 属性の値 [CODE(DOM)@en[unloaded]] (DOM)
[16] [CODE(DOMi)@en[[[Document]]]] [[オブジェクト]]の [CODE(DOMa)@en[[[visibilityState]]]]
[[属性]]は、[[最上位閲覧文脈]]に含まれている [CODE(DOMi)@en[[[Document]]]] が[[unload]]の過程にある時は、
[DFN[[CODE(DOM)@en[[[unloaded]]]]]] を返す[['''べきです''']]。 [SRC[>>17]]
;; [18] [CODE(DOM)@en[[[unloaded]]]] という値には対応しなくても構わない [SRC[>>17]] とされています。
;; [19] [CODE(JS)@en[[[document.hidden]]]] は[[偽]]になります。
[34] この値は現在は削除され、 [CODE[[[hidden]]]] とされています。
* メモ
[8] [CITE@en[(X)HTML5 Tracking]]
([TIME[2009-10-12 14:36:54 +09:00]] 版)
<http://html5.org/tools/web-apps-tracker?from=4104&to=4105>
[9] [CITE[Surfin’ Safari - Blog Archive » WebKit Page Cache II – The unload Event]]
([TIME[2009-10-25 15:54:55 +09:00]] 版)
<http://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/>
[10] [CITE[''''''[''''''whatwg'''''']'''''' Declarative unload data]]
( ([TIME[2012-05-08 08:28:55 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-May/035686.html>
[11] [CITE[''''''[''''''whatwg'''''']'''''' Declarative unload data]]
( ([TIME[2012-05-08 08:29:21 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-May/035706.html>
[12] [CITE[Issue 113605 - chromium - Fire event unload, onbeforeunload, pagehide - An open-source browser project to help move the web forward. - Google Project Hosting]]
([TIME[2012-05-11 17:14:26 +09:00]] 版)
<http://code.google.com/p/chromium/issues/detail?id=113605#c2>
[13] [CITE@en[Web Applications 1.0 r7318 Allow script termination dialogs to close the page too.]]
( ([TIME[2012-09-06 01:48:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7317&to=7318>
[14] [CITE[''''''[''''''whatwg'''''']'''''' Declarative unload data]]
( ([TIME[2012-11-21 02:05:52 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-November/038040.html>
[15] [CITE[''''''[''''''whatwg'''''']'''''' events when navigating away before page load?]]
( ([TIME[2012-12-15 06:00:01 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-December/038344.html>
[20] [CITE@en[Web Applications 1.0 r8609 align 'load' and 'unload' events since they have similar quirks in practice]]
( ([TIME[2014-05-07 07:16:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8608&to=8609>
[21] [CITE[Part2 - browsersec - Browser Security Handbook, part 2 - Browser Security Handbook - Google Project Hosting]]
([TIME[2015-03-31 16:49:11 +09:00]] 版)
<https://code.google.com/p/browsersec/wiki/Part2#Page_transition_logic>
[40] [CITE@en[Remove the storage mutex due to lack of implementation · whatwg/html@1b918cf]] ([TIME[2015-12-16 14:38:10 +09:00]] 版) <https://github.com/whatwg/html/commit/1b918cf72fcbba011f83b92ab5d1f483fb1cafa3>