Notifications API 的通知接口用于向用户配置和显示桌面通知。
Object.prototype
Function.prototype
EventTarget
Notification
new Notification(title, options)
| 属性 | 说明 |
|---|---|
| permission | 只读,一个用于表明当前通知显示授权状态的字符串。可能的值包括:denied (用户拒绝了通知的显示), granted (用户允许了通知的显示), or default (因为不知道用户的选择,所以浏览器的行为与 denied 时相同). |
| 语法 | 说明 |
|---|---|
| requestPermission() | 用于当前页面想用户申请显示通知的权限。这个方法只能被用户行为调用(比如:onclick 事件),并且不能被其他的方式调用。 |
Object.prototype
EventTarget.prototype
Notification.prototype
从其父级继承的属性请查阅: EventTarget。
| 属性 | 说明 |
|---|---|
| title | 只读 (moz only)在构造方法中指定的 title 参数。 |
| dir | 只读,通知的文本显示方向。在构造方法的 options 中指定。 |
| lang | 只读,通知的语言。在构造方法的 options 中指定。 |
| body | 只读,通知的文本内容。在构造方法的 options 中指定。 |
| tag | 只读,通知的 ID。在构造方法的 options 中指定。 |
| icon | 只读,通知的图标图片的 URL 地址。在构造方法的 options 中指定。 |
从其父级继承的方法请查阅: EventTarget.
| 语法 | 说明 |
|---|---|
| close() | |
| addEventListener() | Register an event handler of a specific event type on the EventTarget. |
| removeEventListener() | Removes an event listener from the EventTarget. |
| dispatchEvent() | Dispatch an event to this EventTarget. |
Object.prototype
EventTarget.prototype
Notification.prototype
Notification 实例