如何将HTML5桌面通知的关闭时间更改为不自动关闭? [英] how to change the close time of the HTML5 desktop notification to not autoclose?

查看:767
本文介绍了如何将HTML5桌面通知的关闭时间更改为不自动关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTML5桌面通知。它运作良好,并根据我的要求给我适当的输出。现在,我想显示该通知,直到用户手动关闭该通知,我的代码可能如下所示。

I am working with the HTML5 desktop notification. it's working well and give me proper output as per my requirements. Now, I want to display that notification until user close that notification manually how it.s possible my code is as following.

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

It stays indefinitely on Chrome. There's a bug in Firefox which auto-closes it after 4 seconds: https://bugzilla.mozilla.org/show_bug.cgi?id=875114

这篇关于如何将HTML5桌面通知的关闭时间更改为不自动关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆