Browser 浏览器默认通知

Browser 浏览器默认通知,browser,notifications,Browser,Notifications,是否有办法在浏览器中弹出通知而不使用任何插拔 <button onclick="notifyMe()">Notify me!</button> 通知我! 通知我! 函数notifyMe(){ //让我们检查一下浏览器是否支持通知 如果(!(“窗口中的通知”){ 警报(“此浏览器不支持桌面通知”); } //让我们检查是否已授予通知权限 else if(Notification.permission==“已授予”){ //如果可以的话,让我们创建一个通知 var通知=新通

是否有办法在浏览器中弹出通知而不使用任何插拔

<button onclick="notifyMe()">Notify me!</button>
通知我!
通知我!
函数notifyMe(){
//让我们检查一下浏览器是否支持通知
如果(!(“窗口中的通知”){
警报(“此浏览器不支持桌面通知”);
}
//让我们检查是否已授予通知权限
else if(Notification.permission==“已授予”){
//如果可以的话,让我们创建一个通知
var通知=新通知(“你好!”);
}
//否则,我们需要请求用户的许可
else if(Notification.permission!=“拒绝”){
Notification.requestPermission(函数(权限){
//如果用户接受,让我们创建一个通知
如果(权限==“已授予”){
var通知=新通知(“你好!”);
}
});
}
}
  <button onclick="notifyMe()">Notify me!</button>

        <script>
        function notifyMe() {
          // Let's check if the browser supports notifications
          if (!("Notification" in window)) {
            alert("This browser does not support desktop notification");
          }

          // Let's check whether notification permissions have already been granted
          else if (Notification.permission === "granted") {
            // If it's okay let's create a notification
            var notification = new Notification("Hi there!");
          }

          // Otherwise, we need to ask the user for permission
          else if (Notification.permission !== 'denied') {
            Notification.requestPermission(function (permission) {
              // If the user accepts, let's create a notification
              if (permission === "granted") {
                var notification = new Notification("Hi there!");
              }
            });
          }

        }
        </script>