Notification.body

 Notification 的只读属性body返回了构造函数Notification实例化时,options所使用的body值。

Note: 此特性在 Web Worker 中可用

语法

var body = Notification.body;

DOMString.

示例

在 Emogotchi demo (see source code)中, 我们在激活一个桌面通知时,调用了spawnNotification()函数—函数被传入了指定的参数 body、icon、title , 创建了一个必选对象传入Notification() 构造函数创建了一个实例.

function spawnNotification(theBody,theIcon,theTitle) {
  var options = {
      body: theBody,
      icon: theIcon
  }
  var n = new Notification(theTitle,options);
}

规范

Specification Status Comment
Notifications API
body
Living Standard Living standard

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)
Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 5 webkit (en-US) (see notes)
22
(Yes) 4.0 moz (en-US) (see notes)
22
未实现 25 6 (see notes)
Available in workers ? ? 41.0 (41.0) ? ? ?
Feature Android Android Webview Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ?

(Yes)

(Yes) 4.0 moz (en-US) (see notes)
22
1.0.1 moz (en-US) (see notes)
1.2
未实现 ? 未实现

(Yes)

Available in workers ? ? ? 41.0 (41.0) ? ? ? ? ?

Firefox OS 备忘

{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}

Chrome 备忘

{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}

Safari 备忘

{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}

相关链接