Tuesday, May 11, 2010

Closing Desktop Notifications on a Timer

So, one of the few things about Chrome’s desktop notifications I’ve been
trying to figure out is how to close them on a timer, and it finally came to me.

timer will only activate when the notification is opened, and will close the notification even if the page
that originally spawned it has been closed.

Create and Show a new HTMLNotification.

[codesyntax lang="html4strict"]<!DOCTYPE html>

<title>Notification Title</title>

<style type="text/css">
body,body* { font-family: sans-serif; font-size: 10pt; }

h1 { font-family: sans-serif; margin: 0; padding: 0; font-size: 12pt; font-weight: bold; }
p {
margin: 0; padding: 0; }
<h1>Notification Title</h1>

<p>Notification Text</p>

will close the window after five seconds and will look just like a normal notification! :D

I learned is: Notification Windows respond to the javascript method self.close()

No comments:

Post a Comment