From 1109132f09d75da9a28b649c7677bb6ce07c40c0 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:45 -0500 Subject: initial commit --- files/es/web/api/notification/onclick/index.html | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 files/es/web/api/notification/onclick/index.html (limited to 'files/es/web/api/notification/onclick') diff --git a/files/es/web/api/notification/onclick/index.html b/files/es/web/api/notification/onclick/index.html new file mode 100644 index 0000000000..211947a1b8 --- /dev/null +++ b/files/es/web/api/notification/onclick/index.html @@ -0,0 +1,61 @@ +--- +title: Notification.onclick +slug: Web/API/notification/onclick +tags: + - API + - DOM + - Notifications + - Propiedad + - Referencia + - onclick +translation_of: Web/API/Notification/onclick +--- +

{{APIRef("Web Notifications")}}

+ +

La propiedad onclick de la interfaz {{domxref("Notification")}} especifica un event listener para recibir eventos {{event("click")}}. Estos eventos ocurren cuando el usuario hace un click sobre el {{domxref("Notification")}} mostrado.

+ +

Sintaxis

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

El comportamiento por defecto es mover el foco al viewport del sitio de contexto de dicha notificación. Si no deseas este comportamiento, puedes llamar preventDefault() en el objeto del evento.

+ +

Ejemplos

+ +

En el siguiente ejemplo, utilizamos un manejador onclick para abrir un sitio web en una nueva pestaña (especificado con la inclusión del parámetro '_blank') una vez que la notifación es cliqueada.

+ +
notification.onclick = function(event) {
+  event.preventDefault(); // Previene al buscador de mover el foco a la pestaña del Notification
+  window.open('http://www.mozilla.org', '_blank');
+}
+ +

Especificaciones

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Notifications','#dom-notification-onclick','onclick')}}{{Spec2('Web Notifications')}}Living standard.
+ +

Compatibilidad de navegadores

+ +

{{Page("/en-US/docs/Web/API/Notification","Browser compatibility")}}

+ +

Mira también

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