Google chrome 点击谷歌通知上的事件

Google chrome 点击谷歌通知上的事件,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我正在为我的网站开发一个google chrome扩展 我希望当用户点击谷歌浏览器的桌面通知时,我的网站就会打开 那么如何处理google chrome桌面通知点击事件呢?基于此: 我是这样解决的: 我创建了一个notification.html文件: <html> <head> <base target="_blank" /> </head> <body> <a href="http://example.com">

我正在为我的网站开发一个google chrome扩展

我希望当用户点击谷歌浏览器的桌面通知时,我的网站就会打开

那么如何处理google chrome桌面通知点击事件呢?

基于此: 我是这样解决的:

我创建了一个notification.html文件:

<html>
<head>
  <base target="_blank" />
</head>
<body>
  <a href="http://example.com">Open site</a>
</body>
</html>

您可以将CSS设置为通知正文中没有文本的完整链接。

如果不想使用HTML通知,可以向通知中添加单击事件处理程序并调用“取消”功能

var notification = window.webkitNotifications.createNotification(
        'url', 'title', 'text');

notification.addEventListener('click', function() {
    notification.cancel();
    window.open('url')
})
notification.show();

webkitNotifications.createHTMLNotification()已不在API中。如果该API已被弃用,是否可以更新答案,而不是将其否决?
var notification = window.webkitNotifications.createNotification(
        'url', 'title', 'text');

notification.addEventListener('click', function() {
    notification.cancel();
    window.open('url')
})
notification.show();