Notification:actions 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

备注: 此特性在 Web Worker 中可用。

Notification 接口的 actions 只读属性提供了可供用户选择以与通知交互的操作。

使用 showNotification() 方法和 Notification() 构造函数的第二个参数的 actions 选项设置操作。

备注: 浏览器通常会限制它们为特定通知显示的最大的操作的数量。检测 Notification.maxActions 静态属性以确定限制的操作的数量。

一个表示操作的只读数组。数组中的每个元素都是一个具有以下成员的对象:

action

一个标识要在通知上显示的用户操作的字符串。

title

一个包含要向用户显示的操作文本的字符串。

icon

一个包含与操作一起显示的图标 URL 的字符串。

规范

Specification
Notifications API
# dom-notification-actions

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
actions
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

参见