From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/window/unload_event/index.html | 121 ++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 files/ja/web/api/window/unload_event/index.html (limited to 'files/ja/web/api/window/unload_event') diff --git a/files/ja/web/api/window/unload_event/index.html b/files/ja/web/api/window/unload_event/index.html new file mode 100644 index 0000000000..019894e002 --- /dev/null +++ b/files/ja/web/api/window/unload_event/index.html @@ -0,0 +1,121 @@ +--- +title: unload +slug: Web/API/Window/unload_event +translation_of: Web/API/Window/unload_event +--- +
{{APIRef}}
+ +

unload イベントは、文書または子リソースがアンロードされるときに発生します。

+ + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{domxref("WindowEventHandlers/onunload", "onunload")}}
+ +

以下のイベントの後に発生します。

+ + + +

文書は以下のような状態にあります。

+ + + +

unload イベントは文書ツリーにも続くことに注意してください。親フレームのアンロードは、子フレームの unload の前に行われます (以下の例を参照)。

+ +

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Parent Frame</title>
+    <script>
+      window.addEventListener('beforeunload', function(event) {
+        console.log('I am the 1st one.');
+      });
+      window.addEventListener('unload', function(event) {
+        console.log('I am the 3rd one.');
+      });
+    </script>
+  </head>
+  <body>
+    <iframe src="child-frame.html"></iframe>
+  </body>
+</html>
+ +

child-frame.html の内容を以下に示します。

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Child Frame</title>
+    <script>
+      window.addEventListener('beforeunload', function(event) {
+        console.log('I am the 2nd one.');
+      });
+      window.addEventListener('unload', function(event) {
+        console.log('I am the 4th and last one…');
+      });
+    </script>
+  </head>
+  <body>
+      ☻
+  </body>
+</html>
+ +

親フレームがアンロードされると、 console.log() のメッセージに記述された順序でイベントが発生します。

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('UI Events', '#event-type-unload', 'unload')}}{{Spec2('UI Events')}} 
+ +

ブラウザーの対応

+ + + +

{{Compat("api.Window.unload_event")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf