--- title: onnotificationclose slug: Web/API/ServiceWorkerGlobalScope/onnotificationclose tags: - API - Experimental - Interface - Property - Reference - ServiceWorkerGlobalScope - onnotificationclose translation_of: Web/API/ServiceWorkerGlobalScope/onnotificationclose --- <p>{{APIRef("Service Workers API")}}</p> <p><code><strong>ServiceWorkerGlobalScope.onnotificationclose</strong></code> プロパティは、{{domxref("ServiceWorkerGlobalScope")}} オブジェクトで {{Event("notificationclose")}} イベントが発行されるとき、つまり、{{domxref("ServiceWorkerRegistration.showNotification()")}} によって生成された表示されている通知をユーザーが閉じるたびに呼び出されるイベントハンドラーです。</p> <p>メインスレッドや {{domxref("Notification.Notification","Notification()")}} コンストラクターを使用した service worker ではない worker で生成された通知は、<code>Notification</code> オブジェクト自身の {{Event("close")}} イベントを受け取ります。</p> <div class="note"> <p><strong>注記</strong>: {{domxref("Notification.Notification","Notification()")}} コンストラクターを使用して {{domxref("ServiceWorkerGlobalScope")}} 内で通知を生成しようとすると、エラーがスローされます。</p> </div> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="syntaxbox" style="font-size: 14px;">ServiceWorkerGlobalScope.onnotificationclose = function(NotificationEvent) { ... }; ServiceWorkerGlobalScope.addEventListener('notificationclose', function(NotificationEvent) { ... });</pre> <h2 id="Example" name="Example">例</h2> <pre class="brush: js">// service worker 内。 self.onnotificationclose = function(event) { console.log('On notification close: ', event.notification.tag); }; </pre> <h2 id="Specifications" name="Specifications">仕様</h2> <table class="standard-table"> <tbody> <tr> <th scope="col"><font face="Open Sans, sans-serif"><span style="font-weight: normal;">仕様</span></font></th> <th scope="col"><font face="Open Sans, sans-serif"><span style="font-weight: normal;">ステータス</span></font></th> <th scope="col"><font face="Open Sans, sans-serif"><span style="font-weight: normal;">コメント</span></font></th> </tr> <tr> <td>{{SpecName('Web Notifications','#dom-serviceworkerglobalscope-onnotificationclose','onnotificationclick')}}</td> <td>{{Spec2('Web Notifications')}}</td> <td>初期定義。このプロパティは {{domxref('ServiceWorkerGlobalScope')}} の一部ですが、{{domxref('Notifications_API')}} イベントで定義されています。</td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> <div> <p>{{Compat("api.ServiceWorkerGlobalScope.onnotificationclose")}}</p> </div>