gpt4 book ai didi

javascript - 在 Firefox 中连续使用 Notifications API 的多个通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:15:14 26 4
gpt4 key购买 nike

我想要多次显示消息,一个接一个地连续显示,为此我使用通知 API,当我在 chrome 浏览器中运行我的代码时,一切都很好但是当我在 firefox 中运行我的代码时,当我使用一个通知构造函数时,每件事很好,并且有多个通知根本没有任何显示!

在代码中:

var options= {
body: 'test1'
};
new window.Notification('subj', options);

这在 chrome 和 firefox 中很好,但是:

var options= {
body: 'test1'
};
new window.Notification('subj', options);
new window.Notification('subj', options);
new window.Notification('subj', options);

在 chrome 中显示三个消息,在 firefox 中不显示。

为什么 firefox 不能像 chrome 一样显示所有通知?

有没有其他方法可以在所有浏览器中完美地在客户端桌面上显示通知?

最佳答案

我的临时解决方案不是很好,但它有效:

new Notification('a');
setTimeout(function() {
new Notification('b');
}, 200);

在我的 Firefox 中,30 毫秒的超时工作正常,20 毫秒没有任何反应。所以我现在使用 200 毫秒来获得一点缓冲,因为我不知道其他浏览器的行为方式......

关于javascript - 在 Firefox 中连续使用 Notifications API 的多个通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33073958/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com