diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/serviceworkerglobalscope/onnotificationclick | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/ja/web/api/serviceworkerglobalscope/onnotificationclick')
| -rw-r--r-- | files/ja/web/api/serviceworkerglobalscope/onnotificationclick/index.html | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/files/ja/web/api/serviceworkerglobalscope/onnotificationclick/index.html b/files/ja/web/api/serviceworkerglobalscope/onnotificationclick/index.html new file mode 100644 index 0000000000..cc9cd0c7b6 --- /dev/null +++ b/files/ja/web/api/serviceworkerglobalscope/onnotificationclick/index.html @@ -0,0 +1,122 @@ +--- +title: ServiceWorkerGlobalScope.onnotificationclick +slug: Web/API/ServiceWorkerGlobalScope/onnotificationclick +tags: + - API + - Experimental + - Interface + - Property + - Reference + - ServiceWorkerGlobalScope + - onnotificationclick +translation_of: Web/API/ServiceWorkerGlobalScope/onnotificationclick +--- +<p style="line-height: 19.0909080505371px;"><span style="line-height: 19.0909080505371px;">{{SeeCompatTable}}{{APIRef("Service Workers API")}}</span></p> + +<p style="line-height: 19.0909080505371px;"><strong>ServiceWorkerGlobalScope.onnotificationclick</strong> プロパティは、{{domxref("ServiceWorkerGlobalScope")}} オブジェクトで {{Event("notificationclick")}} イベントが送り出されるたびに呼び出されるイベントハンドラーです。つまり、<span style="line-height: 19.0909080505371px;">ユーザーが {{domxref("ServiceWorkerRegistration.showNotification()")}} で生成された通知をクリックしたときです。</span></p> + +<p>メインスレッド、または {{domxref("Notification.Notification","Notification()")}} コンストラクターを使用して Service Worker ではない Worker で生成された通知は、<code>Notification</code> オブジェクト自体で {{Event("click")}} イベントを代わりに受け取ります。</p> + +<div class="note"> +<p><strong>ノート</strong>: {{domxref("Notification.Notification","Notification()")}} コンストラクターを使用して {{domxref("ServiceWorkerGlobalScope")}} 内で通知を生成しようとすると、エラーがスローされます。</p> +</div> + +<h2 id="構文" style="line-height: 30px; font-size: 2.14285714285714rem;">構文</h2> + +<pre class="brush: js" style="font-size: 14px;">ServiceWorkerGlobalScope.onnotificationclick = function(NotificationEvent) { ... }; +</pre> + +<h2 id="例">例</h2> + +<pre class="brush: js">self.onnotificationclick = function(event) { + console.log('On notification click: ', event.notification.tag); + event.notification.close(); + + // This looks to see if the current is already open and + // focuses if it is + event.waitUntil(clients.matchAll({ + type: "window" + }).then(function(clientList) { + for (var i = 0; i < clientList.length; i++) { + var client = clientList[i]; + if (client.url == '/' && 'focus' in client) + return client.focus(); + } + if (clients.openWindow) + return clients.openWindow('/'); + })); +}; +</pre> + +<h2 id="仕様">仕様</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-onnotificationclick','onnotificationclick')}}</td> + <td>{{Spec2('Web Notifications')}}</td> + <td>初期定義。このプロパティは、{{domxref('ServiceWorkerGlobalScope')}} の一部だが {{domxref('Notifications_API')}} で定義されている。</td> + </tr> + </tbody> +</table> + +<h2 id="ブラウザー実装状況">ブラウザー実装状況</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{CompatChrome(42.0)}}</td> + <td>{{ CompatGeckoDesktop("44.0") }}<sup>[1]</sup></td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>機能</th> + <th>Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>Firefox OS</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>基本サポート</td> + <td>{{CompatUnknown}}</td> + <td>{{ CompatGeckoMobile("44.0") }}</td> + <td>{{ CompatVersionUnknown }}</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(42.0)}}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] Service worker(と <a href="/ja/docs/Web/API/Push_API">Push</a>)は、<a href="https://www.mozilla.org/ja/firefox/organizations/">Firefox 45 延長サポート版</a>(ESR)では使用できません。</p> |
