chrome中的请求通知权限失败

时间:2016-01-13 15:20:03

标签: javascript google-chrome

我编写了一个简单的脚本,该脚本应该提示用户提供通知权限。

在Firefox 43中运行时,它会显示"已授予" ,而Chrome 47会在不提示用户的情况下显示"拒绝" (Firefox也没有提示)。

<html>
<head>
</head>
<body>
    <script>
        Notification.requestPermission(function (result) {

            console.log(result); // Chrome displays "denied"
        });
    </script>
</body>

1 个答案:

答案 0 :(得分:1)

如果我更改浏览器设置以阻止所有通知,我可以得到您描述的症状。

Settings > Advanced > Content Settings > Notificaitons
Do not allow any site to show notifications - 这是否已经过检查?

您需要将其设置为其他2个选项中的任何一个。一些有用的资源是here (Chrome blog)here (sandbox)