Returns the string ID of the notification button the user clicked. This value returns an empty string if the user clicked the notification somewhere other than an action button, or the notification does not have a button. The notification id is set during the creation of the Notification via the actions array attribute and can't be modified unless the notification is replaced.
A
DOMString
对象。
self.registration.showNotification("New articles available", {
actions: [{action: "get", title: "Get now."}]
});
self.addEventListener('notificationclick', function(event) {
event.notification.close();
if (event.action === 'get') {
synchronizeReader();
} else {
clients.openWindow("/reader");
}
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
|
Notifications API
The definition of 'action' in that specification. |
实时标准 | Living standard. |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
action
|
Chrome 48 | Edge ≤18 |
Firefox
44
|
IE ? | Opera No | Safari ? | WebView Android No | Chrome Android 48 | Firefox Android 44 | Opera Android No | Safari iOS ? | Samsung Internet Android 5.0 |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
见实现注意事项。
NotificationEvent
action
notification