Back to Content

Notification: body property

files/en-us/web/api/notification/body/index.md

latest747 B
Original Source

{{APIRef("Web Notifications")}}{{securecontext_header}} {{AvailableInWorkers}}

The body read-only property of the {{domxref("Notification")}} interface indicates the body string of the notification, as specified in the body option of the {{domxref("Notification.Notification","Notification()")}} constructor.

Value

A string.

Examples

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

  console.log(n.body);
}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also