The W3C specification for Web Notifications is still in draft but outlines the concept well. The website must request permission and then may publish notifications for the browser to display.
Google Chrome / Chromium
Chromium has published their API specification and it closely resembles the W3C specification. The onclick attribute is currently missing and onshow is called ondisplay.
Sadly Firefox 4 will not have support for Web Notifications. Bug 594543 is currently tracking the implementation for a future version but does not have a milestone listed. It's slightly concerning that the bug author is already suggesting a deviation from the W3C specification - they would rather include a callback on the Notification constructor instead of implementing the onshow, onclick, onerror, and onclose attributes.
The last example uses setTimeout to call cancel after 15 seconds. This seems like a good way to ensure the popup is closed; however, I'm slightly surprised they did not call setTimeout within the Notification's onshow method. Unless the notification is immediately displayed the setTimeout timer is needlessly wasting time. The rationale for this choice may be because there is no guarantee that the onshow method will be called immediately.
Post a Comment