title: Prevent Firefox Web Notifications from automatically Closing
body: <p>I've got Web Notifications working in Firefox in combination with Server Sent DOM events. Unfortunately the notifications disappear after about two to three seconds. I prefer Chrome's method of leaving the message visible (with a maximum of three displayed at any given time) until the user clicks the notification.</p>
  
  <p>Here is what I have...</p>
  
  <pre><code>window.onload = function(e)
  {
   if ('EventSource' in window)
   {//Server Sent DOM Events
    var sse = new EventSource('../mail/sse/');
  
    if (Notification.permission &amp;&amp; Notification.permission!='granted')
    {
     Notification.requestPermission(function(status) {if (Notification.permission!=status) {Notification.permission = status;}});
    }
    else if (window.webkitNotifications &amp;&amp; window.webkitNotifications.checkPermission()!=0)
    {
     document.getElementsByTagName('body')[0].addEventListener('click',function() {window.webkitNotifications.requestPermission();},false);
    }
  
    es.onclick = function(sse)
    {
     //
    }
  
    //doesn't work
    es.onclose = function(es) {es.preventDefault();}
  
    es.onmessage = function(sse)
    {
     if ('Notification' in window)
     {
      if (window.webkitNotifications)
      {
       var n = webkitNotifications.createNotification('images/stuff.gif','New Email Message(s)',sse.data);
       n.show();
       n.onshow = function() {setTimeout(notification.close,15000);}
      }
      else
      {
       var n = new Notification('New Email Message(s)',{icon:'images/stuff.gif',body:sse.data});
      }
     }
    }
   }
  }
  </code></pre>