How to save notification in firefox?

I have a chat program and I expect people to leave their table. When they return, I want the notifications to still be on the screen. Chrome may leave notifications forever, but autofox closes automatically. This is not great because users will not look at their monitors.

Firefox seems to automatically close notifications. Is there a good way to open it?

+1
source share
1 answer

Currently, I just re-open the notification when it closes, and when I explicitly close it (by clicking), I allow it to actually close.

// This assumes you already checked for permissions and have notifications working var MyNotify = function(message) { this.message = message; this.open(); }; MyNotify.prototype.open = function() { var self = this; // Notification is the native browser method self.instance = new Notification(self.message); self.instance.addEventListener('close', function(){ // We force firefox to continually respawn notifications until they explicitly close if (!self.shouldClose) self.open(); }); self.instance.addEventListener('click', function(){ self.close(); }); }; MyNotify.prototype.close = function() { self.shouldClose = true; self.instance.close(); }; new MyNotify('Hello World'); 
+3
source

Source: https://habr.com/ru/post/979198/


All Articles