/
388.txt
256 lines (182 loc) · 11.7 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
* 仕様書
[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]]]] [SRC[>>22]] するには、
[FIG(list members)[
: [VAR[文書]] : [[unload]] する[[文書]]。
: [VAR[再帰フラグ]] : [[boolean]]。[[再帰呼び出し]]かどうかを表します。
既定値は[[偽]]です。
]FIG]
... について、次のようにします [SRC[>>22]]。
[FIG(steps)[
= [[文書]]の [[unload a document]] 呼び出し済みフラグを[[真]]に設定します。
([CODE(JS)@en[[[document.open]]]] で使います。)
= [25] [VAR[文書]]の[F[イベントループ]]の [F[termination nesting level]] を、
[N[1]] [[インクリメント]]します。
= [46] [VAR[文書]]の [F[ignore-opens-during-unload counter]] を、
[N[1]] [[インクリメント]]します。
= [47] [F[文書]]の [F[page showing]] が[[真]]の場合、
== [48] [VAR[文書]]の [F[page showing]] を、[[偽]]に設定します。
== [49] [[イベントを発火]]します。
[FIG(list members middle)[
:[[インターフェイス]]:[CODE(DOMi)@en[[[PageTransitionEvent]]]]
:[[イベント型]]:[CODE(DOMe)@en[[[pagehide]]]]
:[[対象]]:[[文書]]の [CODE(DOMi)@en[[[Window]]]]
:[[target override]]:[[文書]]
:[[trusted]]:[[真]]
:[[bubbles]]:[[偽]]
:[[取り消し可能]]:[[偽]]
:[CODE(DOMa)@en[[[persisted]]]]:[[文書]]の [[''salvageable'']]
]FIG]
== [50] [VAR[文書]]について[[unloading document visibility change steps]] を実行します。
= [36] [VAR[文書]]の [F[fired unload]] が[[偽]]の場合、
== [35] [[イベントを発火]]します。
[FIG(list members middle)[
:[[イベント型]]:[CODE(DOMe)@en[[[unload]]]]
:[[対象]]:[[文書]]の [CODE(DOMi)@en[[[Window]]]]
:[[target override]]:[[文書]]
]FIG]
= [38] [VAR[文書]]の[F[イベントループ]]の [F[termination nesting level]] を、
[N[1]] [[デクリメント]]します。
= [39] 先の [CODE(DOMe)@en[[[unload]]]] [[イベント]]の[[発火]]で何らかの[[イベントリスナー]]が実行されていれば、
== [52] [VAR[文書]]の [F[''salvageable'']] を、[[偽]]に設定します。
== [53] [VAR[文書]]の [F[fired unload]] を、[[真]]に設定します。
= [51] [VAR[文書]]について [[unloading document cleanup steps]] を実行します。
= [37] [VAR[再帰フラグ]]が[[偽]]の場合、
== [54] [VAR[文書]]の[F[子孫閲覧文脈のリスト]]の各[[閲覧文脈]][VAR[閲覧文脈]]について、
=== [55] [VAR[閲覧文脈]]の[F[活性文書]]について [[unload a document]] を実行します。
[VAR[再帰フラグ]]は[[真]]とします。
=== [56] [VAR[閲覧文脈]]の[F[活性文書]]の [F[''salvageable'']] が[[偽]]の場合、
==== [57] [VAR[文書]]の [F[''salvageable'']] を、[[偽]]に設定します。
== [58] [VAR[文書]]の [F[''salvageable'']] が[[偽]]の場合、
=== [59] [VAR[文書]]を[[捨てます][文書を捨てる]]。
= [60] [VAR[文書]]の [F[ignore-opens-during-unload counter]] を、
[N[1]] [[デクリメント]]します。
]FIG]
[23] [[文書]]は、 [DFN[[F[fired unload]]]] フラグを持ちます。
初期値は[[偽]]です [SRC[>>22]]。
[[文書のunload]]で参照される他に、 [CODE(JS)@en[document.open]]
でも値が設定されます。
[26] [[unload a document]] の実行中か否かは、[[文書読み込みを停止]]の処理に影響します。
[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]] が呼び出されることがあります。
[HISTORY[
[30] [CODE(JS)@en[[[document.open]]]] は、 [[unload a document]] を呼び出すことがあります。
]HISTORY]
[32] [[unload a document]] を呼び出す場合は、それより前に [[prompt to unload a document]]
が呼び出されています。
@@ [44] [[WebDriver]] の[[スクリプト]]等が実行中の場合、...
* 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>
[41] [CITE@en['''['''''']''' (0) Placeholder for beforeunload/unload; interaction of document.o…]]
( ([[Hixie]]著, [TIME[2007-04-21 14:30:09 +09:00]]))
<https://github.com/whatwg/html/commit/c1994a485446ab0fbfb7048df10bb081947f6405>
[42] [CITE@en['''['''giow''']''' (2) Make sure to fire the relevant events on the Window object…]]
( ([[Hixie]]著, [TIME[2009-01-21 20:34:10 +09:00]]))
<https://github.com/whatwg/html/commit/afdba55e4ae45f4c9d42c00902da1a0df7381aad>
[43] [CITE@en[Disallow *all* navigations during unload, not just cross-origin]]
([[domenic]]著, [TIME[2016-09-16 01:20:25 +09:00]])
<https://github.com/whatwg/html/commit/2a11eef8f92b0335328890dc2cb1e281d18553eb>
[45] [CITE@en[Editorial: use a flag to track recursive "unload a document"]]
([[gterzian]]著, [TIME[2018-04-21 05:16:04 +09:00]])
<https://github.com/whatwg/html/commit/d9249d166174f08fe30d843731bfeb58cfb4117c>
[61] [CITE@en[add recusiveFlag argument to unload by gterzian · Pull Request #3632 · whatwg/html]]
([TIME[2018-04-21 18:13:23 +09:00]])
<https://github.com/whatwg/html/pull/3632>
[62] [CITE@en[Editorial: modernize the style of various document-accepting algorithms]]
([[musgravejw]]著, [TIME[2018-05-03 01:20:53 +09:00]])
<https://github.com/whatwg/html/commit/8bd6fb3972aab1debd2c562b31617e7d3da2377b>
[63] [CITE@en[Various algorithms should take an explicit document argument · Issue #3638 · whatwg/html]]
([TIME[2018-05-03 11:19:48 +09:00]])
<https://github.com/whatwg/html/issues/3638>
[64] [CITE@en[Editorial: Add Document to argument list explicitly for document algorithms by musgravejw · Pull Request #3639 · whatwg/html]]
([TIME[2018-05-03 11:20:34 +09:00]])
<https://github.com/whatwg/html/pull/3639>
[65] [CITE@en[document.open() simplifications, part 1]]
([[TimothyGu]]著, [TIME[2018-08-17 07:20:44 +09:00]])
<https://github.com/whatwg/html/commit/6f769b8089a843066aa19f5991405bf4c84458b3>
[66] [CITE@en[document.open() simplifications, part 1]]
([[TimothyGu]]著, [TIME[2018-08-17 07:20:44 +09:00]])
<https://github.com/whatwg/html/commit/6f769b8089a843066aa19f5991405bf4c84458b3>
[67] [CITE@en[document.open() simplifications: realm creation, unloading, tasks removal by TimothyGu · Pull Request #3918 · whatwg/html]]
([TIME[2018-08-23 20:19:35 +09:00]])
<https://github.com/whatwg/html/pull/3918>
[68] [CITE@en[document.open() simplifications: realm creation, unloading, tasks removal by TimothyGu · Pull Request #3918 · whatwg/html]]
([TIME[2018-08-23 20:19:35 +09:00]])
<https://github.com/whatwg/html/pull/3918>