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/notification/onclick/index.html | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 files/ja/web/api/notification/onclick/index.html (limited to 'files/ja/web/api/notification/onclick') diff --git a/files/ja/web/api/notification/onclick/index.html b/files/ja/web/api/notification/onclick/index.html new file mode 100644 index 0000000000..8534ad4c7b --- /dev/null +++ b/files/ja/web/api/notification/onclick/index.html @@ -0,0 +1,67 @@ +--- +title: Notification.onclick +slug: Web/API/Notification/onclick +tags: + - API + - DOM + - Notification + - Notifications + - Notifications API + - Property + - Reference + - onclick + - プロパティ + - 通知 +translation_of: Web/API/Notification/onclick +--- +

{{APIRef("Web Notifications")}}{{AvailableInWorkers}}{{securecontext_header}}

+ +

onclick は {{domxref("Notification")}} インターフェイスのプロパティで、 {{domxref("Element/click_event", "click")}} イベントを受信するイベントリスナーを指定します。これらのイベントはユーザーが表示されている {{domxref("Notification")}} をクリックしたときに発生します。

+ +

構文

+ +
Notification.onclick = function(event) { ... };
+
+ +

既定の動作は、この通知に関連した閲覧コンテキストへフォーカスを移動することです。この動作をさせたくない場合は、イベントオブジェクトの {{domxref("Event/preventDefault", "preventDefault()")}} を呼び出してください。

+ +

+ +

以下の例では、 onclick ハンドラーを使用して、通知がクリックされたときにウェブページを新しいタブで開くようにしています (_blank を含めて指定することで指定)。

+ +
notification.onclick = function(event) {
+  event.preventDefault(); // prevent the browser from focusing the Notification's tab
+  window.open('http://www.mozilla.org', '_blank');
+}
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Web Notifications','#dom-notification-onclick','onclick')}}{{Spec2('Web Notifications')}}Living standard
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Notification.onclick")}}

+ +

関連情報

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