Ver Mensaje Individual
  #7 (permalink)  
Antiguo 05/07/2012, 19:11
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: notificaciones en html5, casi funcionando..

Es mas o menos asi
vos tenes esto

Código Javascript:
Ver original
  1. $('#show_html_notification').click(function () {
  2.                     if (window.Notifications.checkPermission() == 0) {
  3.                         createNotification('html');
  4.                     } else {
  5.                         window.Notifications.requestPermission();
  6.                     }
  7.                 });                            
  8.             } else {
  9.         alert('HTML 5 Notifications are not supported on this browser/OS.');
  10.         }
  11.         });

estás usando jQuery para que en el evento click se genere la notificación, vos decis que no necesitas de ese click. Entonces quitamos el click, definis una función, y le haces setInterval para que se ejecute cada minuto, o el tiempo que desees

Código Javascript:
Ver original
  1. function notificar(){      
  2.         if (window.webkitNotifications) {
  3.             window.Notifications = window.webkitNotifications;                              
  4.  
  5.                     if (window.Notifications.checkPermission() == 0) {
  6.                         createNotification('html');
  7.                     } else {
  8.                         window.Notifications.requestPermission();
  9.                     }
  10.                            
  11.             } else {
  12.         alert('HTML 5 Notifications are not supported on this browser/OS.');
  13.         }
  14.      
  15.  }


<body onload="setInterval('notificar()', 60000"> --> 1 minuto
El alert indicando que el navegador no soporta el método, lo pondria fuera de la función notificar para que se ejecute solo una vez.

Te aclaro que tus funciones no las revisé, supongo que tu "casi", significa que están bien
SAludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.