我正在使用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);
}
});
}
}
最佳答案