Copyright ©2006 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document defines APIs for alerting the user outside of a web page by displaying notifications with Web content provided on a URL. For a broader overview of notifications, including definitions and use cases, see Notifications Overview.
This document extends and depends on Notifications specification providing text/icon notifications [NOTIFICATIONS].
This document is an Editor's Draft and is not suitable for purposes other than reviewing the specification being developed.
This section is not normative.
This specification extends the capabilities of Notifications defined in [NOTIFICATIONS] by allowing the notification to contain content supplied by a URL, such as HTML or SVG, allowing for interactive and dynamic notifications.
Throughout this document, "notification permission is allowed" shall mean that
the permission level of the 'notifications' feature for the current
security origin is USER_ALLOWED or DEFAULT_ALLOWED
in the meaning of [PERMISSIONS], and "notification permission is denied" shall mean
that the current permission level has some other value.
In addition to displaying simple notifications, some user agents may use a notification platform that is capable of displaying notifications which contain web content, such as HTML or SVG. This supplemental interface exposes that ability.
supplemental NotificationCenter interface
[Supplemental] interface NotificationCenter { Notification createWebNotification(in DOMString url) raises(Exception); };
createWebNotificationurl
of type
DOMString |
A notification object representing the new notification. |
| Exception |
If notification permissions are denied, this method will throw a
If the URL is invalid or cannot be resolved, a |
This section is not normative.
User agents which use an existing notification platform and support only simple notifications may not support all types of web content. These user agents may attempt to extract simple notification content from web content such as the <title> tag of HTML content as the notification.
A web notification is a separate window, and script running within that context should be able to communicate to other windows, subject to the rules which generally apply to cross-domain communication.
Within a web notification, the window.opener property should be
set to the window which created the notification. If the notification was
created by a worker script, window.opener should be null.
The following example uses window.opener to return to the application
which created the notification in response to a click, and then close the notification.
notification.html
---
New email arrived!
<a href="#" onclick="window.opener.focus(); window.close();">
Go to Inbox
</a>
script.js
---
var notification = window.notifications.createWebNotification("notification.html");
notification.show();These algorithm supersede the corresponding algorithms in [NOTIFICATIONS], providing for the fetching of the content URL.
When a user agent is to display a notification, the user agent should perform the following steps:
url using the algorithm defined in [HTML5].
error event on the notification
object and stop executing this algorithm.
display event on the notification object.When a user agent is to replace a notification, the user agent should perform the following steps. Let old be the notification to be replaced by new.
url resource in new using the algorithm defined in [HTML5].
error event on the new notification
object and stop executing this algorithm,m returning the error information. The old notification is not affected.
close event on the old notification object.display event on the new notification object.