Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2012, 17:07
desoler
 
Fecha de Ingreso: agosto-2008
Ubicación: Miami, FL
Mensajes: 210
Antigüedad: 15 años, 8 meses
Puntos: 2
Pregunta notificaciones en html5, casi funcionando..

hola gente,
Estoy estudiando esto de la Api de notificaciones de html5 y he logrado que me funcione, siempre y cuando presione un boton para ejecutar la notificación.
Lo que no puedo conseguir es que ese notificación se ejecute automaticamente al recibir una variable. Cuando hago click en este link:
Código HTML:
Ver original
  1. <a href="#" id="show_html_notification" style="margin-bottom:25px;font-size:11px;margin-left:-17px;margin-top:25px;">Activate Notification</a>

se ejecuta este script que carga un php el cual levanta datos de la BD y la notificación funciona perfectamente.

Código Javascript:
Ver original
  1. $(document).ready(function () {        
  2.         if (window.webkitNotifications) {
  3.             window.Notifications = window.webkitNotifications;                             
  4.         $('#show_html_notification').click(function () {
  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.  
  16.       function createNotification(type) {
  17.     if(type != 'html')
  18.     var notification = window.Notifications.createNotification("You have received HTML 5 Notification");
  19.     else
  20.     var notification = window.Notifications.createHTMLNotification('content.php');
  21.             notification.show();
  22.         }

Yo necesito que ese boton no se necesite presionar, si no que se ejecute solo cada x tiempo (30 segundo) que es cuando se conecta a la BD y lee si hay nueva notificación, se que estoy cerca, pero no logro que ese boton se auto-presione solo y me ejecute el código javascript.

Desde ya les agradezco el tiempo prestado.
__________________
Se invierte mas dinero en cirugía de pechos y viagra que en la cura del Alzheimer. En unos años tendremos viejas con grandes tetas y viejos con erecciones pero que no recordarán para que sirven..