【发布时间】:2011-06-29 17:35:54
【问题描述】:
我正在尝试在我的网站上实现对 WebKit 的本机桌面通知的支持。当我尝试请求用户允许使用通知时,绝对没有任何反应。例如,以下 HTML 不会提示 Chrome 请求我的许可:
<html lang="en">
<head></head>
<body>
<h1>Testing</h1>
<script>
window.webkitNotifications.requestPermission();
</script>
</body>
</html>
我知道我的 Chrome 版本没有问题,因为其他网站(例如 http://www.html5rocks.com/tutorials/notifications/quick/)运行良好:我可以看到提示和后续通知。
【问题讨论】:
-
即使您获得了弹出权限栏,如果您使用本地 file:/// URL,通知仍然不会显示。将文件移动到 http:// 位置后,
window.webkitNotifications.createNotification.show()将显示通知。 -
那我们如何在本地测试呢? @DanDascalescu
标签: html google-chrome webkit notifications html5-notifications