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/fr/web/api/notification/onclick/index.html | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 files/fr/web/api/notification/onclick/index.html (limited to 'files/fr/web/api/notification/onclick') diff --git a/files/fr/web/api/notification/onclick/index.html b/files/fr/web/api/notification/onclick/index.html new file mode 100644 index 0000000000..209d7c519f --- /dev/null +++ b/files/fr/web/api/notification/onclick/index.html @@ -0,0 +1,63 @@ +--- +title: Notification.onclick +slug: Web/API/notification/onclick +tags: + - API + - DOM + - Notifications + - Propriété + - Reference + - onclick +translation_of: Web/API/Notification/onclick +--- +

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

+ +

La propriété onclick, rattachée à l'interface {{domxref("Notification")}}, définit un gestionnaire d'évènement à déclencher lorsque la notification recçoit un évènement {{event("click")}} (qui se produit lorsqu'un utilisateur clique sur la notification).

+ +

Syntaxe

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

Le comportement par défaut consiste à déplacer le focus sur la zone d'affichage (viewport) du contexte de navigation de la notification. Pour éviter ce comportement, on pourra appeler la méthode preventDefault() sur l'objet représentant l'évènement.

+ +

Exemples

+ +

Dans l'exemple qui suit, on utilise le gestionnaire d'évènement onclick pour ouvrir une page dans un nouvel onglet (avec le paramètre '_blank') lorsqu'on clique sur la notification :

+ +
notification.onclick = function(event) {
+  event.preventDefault(); // empêcher le navigateur de passer le focus sur l'onglet de la navigation
+  window.open('http://www.mozilla.org', '_blank');
+}
+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('Web Notifications','#dom-notification-onclick','onclick')}}{{Spec2('Web Notifications')}}Standard évolutif
+ +

Compatibilité des navigateurs

+ + + +

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

+ +

Voir aussi

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