![]() |
1
746
在现代浏览器中,有两种类型的通知:
API调用采用相同的参数(除了操作-在桌面通知上不可用),这些参数在 MDN Google's Web Fundamentals 地点。
permission for the Notification API may no longer be requested from a cross-origin iframe
,所以我们不能用StackOverflow的代码片段演示。您需要将此示例保存在站点/应用程序的HTML文件中,并确保使用
我们用的是 W3C Notifications 应用程序编程接口。不要把这和 Chrome extensions notifications API ,这是不同的。Chrome扩展通知显然只在Chrome扩展中工作,不需要用户的任何特殊权限。 W3C通知可以在许多浏览器中工作(请参阅上的支持) caniuse ),并且需要用户权限。作为一种最佳实践,不要一开始就要求获得这种许可。 Explain to the user first why they would want notifications 看看其他人 push notifications patterns . 请注意,Chrome在Linux上不支持通知图标,因为 this bug . 最后一句话
现在最新的标准是 https://notifications.spec.whatwg.org/ 至于为什么会有两个不同的调用具有相同的效果,这取决于您是否在服务工作者中—请参阅 this ticket I filed while I worked at Google . notify.js 对于助手库。 |
![]() |
2
90
检查
design
和
API specification
(它仍然是一个草稿)或检查源代码(页面不再可用)以获得一个简单的示例:它主要是对
|
![]() |
3
34
看来
|
![]() |
4
14
http://www.html5rocks.com/en/tutorials/notifications/quick/#toc-examples
但它使用了旧的变量,所以演示不再有效。
|
![]() |
5
5
从这里获取notify.js文件 https://github.com/gravmatt/js-notify 把它放到你的网页上。 把它放在凉亭上
工作原理如下:
|
![]() |
6
4
|
![]() |
7
3
|
![]() |
8
3
js是新webkit通知的包装器。效果不错。 http://alxgbsn.co.uk/2013/02/20/notify-js-a-handy-wrapper-for-the-web-notifications-api/ |
![]() |
user3425506 · 没有互联网连接无法获得PWA 5 月前 |
![]() |
sunics · jQuery在ul中查找li元素 1 年前 |
![]() |
Curious66 · 如何在谷歌会议中捕获传入的音频流 1 年前 |