本文介绍了如何在Firefox中保持通知打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个聊天程序,我希望人们离开他们的办公桌。当他们回来时,我希望通知仍然在屏幕上。 Chrome可以永久保留通知,但firefox会自动关闭。这不是很好,因为用户不会盯着他们的显示器
I have a chat program and I expect people to leave their desk. When they come back, I would like notifications to still be on the screen. Chrome can leave up notifications forever, but firefox auto closes. This isn't great because users aren't going to be staring at their monitors
Firefox似乎会自动关闭通知。是否有一种很好的方法可以让它保持打开状态?
Firefox seems to auto close notifications. Is there a nice way to keep it open?
推荐答案我目前只是在关闭通知时重新打开通知我明确关闭它(点击一下),然后我允许它实际关闭。
I am currently just re-opening the notification when it closes, and when I explicitly close it(with a click), then I allow it to be actually closed.
// 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');更多推荐
如何在Firefox中保持通知打开?
发布评论