如何在Firefox中保持通知打开?

编程入门 行业动态 更新时间:2024-10-27 06:19:36
本文介绍了如何在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中保持通知打开?

本文发布于:2023-11-06 17:47:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564375.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   如何在   Firefox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!