Notification:silent 属性

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

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

Notification 接口的 silent 只读属性指定通知是否应当保持静默,即无论设备设置如何,都不发出声音或振动。该属性在Notification() 构造函数的 silent 选项中指定。

一个布尔值。默认值是 false;设为 true 将使通知静音。

示例

以下代码片段旨在触发静默通知;创建一个简单的 options 对象,然后调用 Notification() 构造函数触发通知。

js
const options = {
  body: "你提交的代码收到了 3 条新的审阅意见。",
  silent: true,
};

const n = new Notification("新评论活动", options);

console.log(n.silent); // true

规范

Specification
Notifications API Standard
# dom-notification-silent

浏览器兼容性

BCD tables only load in the browser

参见