Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I close all notifications of a page before unload it (without use Window#onunload)?

I have a page that notifies the user about server updates, using window.webkitNotifications.

It's not a Google Chrome extension.

I want to close all page notifications before the page unload. I'm trying to do it with:

var notifications = new Array();

// ...
var popup = window.webkitNotifications.createNotification(...);
// ...
notifications.push(popup);

// ...
function closeAll(){
  for (notification in notifications) {
    notifications[notification].cancel();
  }
}

//...
$(window).unload(function() {
  closeAll();
});

But the notifications are not closed when I reloads the page. I found this issue on Chromium project: https://code.google.com/p/chromium/issues/detail?id=40262

How can I ensure that page notifications are closed without use the Window#onunload ?

like image 684
diogenes.falcao Avatar asked May 11 '11 23:05

diogenes.falcao


1 Answers

I wonder if you can add some javascript to the notification popup and settimeout withing the actual popup, that way it will close eventually.

I will have to try and test this out.

like image 180
tsquillario Avatar answered Nov 15 '22 20:11

tsquillario