我正在使用 HTML5 桌面通知。它运作良好,并根据我的要求给我适当的输出。现在,我想显示该通知,直到用户手动关闭该通知。我的代码可能如下所示。
function notifyMe() {
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
else if (Notification.permission === "granted") {
var options = {
body: "due to your inactive response timer is stoped automatically. Start your timer again.",
dir : "ltr"
};
var notification = new Notification("Your timer is stop",options);
}
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (!('permission' in Notification)) {
Notification.permission = permission;
}
if (permission === "granted") {
var options = {
body: "due to your inactive response timer is stoped automatically. Start your timer again.",
dir : "ltr"
};
var notification = new Notification("Your timer is stop",options);
}
});
}
}
最佳答案
它会无限期地保留在 Chrome 上。 Firefox 中有一个 4 秒后自动关闭的错误:https://bugzilla.mozilla.org/show_bug.cgi?id=875114
关于javascript - 如何将 HTML5 桌面通知的关闭时间更改为不自动关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27291297/