In this short tutorial, I will describe how to use the HTML5 Notification API ( currently in Draft ), to be able to display "Notifications" from your web application.
In case you are wondering what a Notification is, it is that small rectangular content that pops out of your system tray, on occasions such as when somebody sends you a message in Gmail Chat, or when Google Now displays its notification on the Desktop.
Here is what it looks like...

They are also known as "Web Notifications". Revised in January, it is expected to make it into the final standard.
So, let's get started.
Click this link : http://jsbin.com/fokadu/9 to see the thing in action. When you click on "Show some notifications", you'll see a notification same as the Image above, pop up from the Notification Area your screen or depending upon your operating system and the location of the Notification Area.
Now let's go through the Source:
http://jsbin.com/fokadu/7/edit?html,css,js,output
The HTML/CSS is pretty standard, nothing worth writing about.
Notice the Javascript.
if(Notification.permission!=="granted") {
Notification.requestPermission();
}
enum
NotificationPermission
{ "default", "denied", "granted" };
"default" refers to the "Uninitialized" state of the particular permission for the particular web-app.
"denied" : refers to the State when the User has "Denied" the permission request.
"granted" : refers to the state when the User has "Allowed" the Permission Request.
interface Notification : EventTarget {
static readonly attribute NotificationPermission permission;
[Exposed=Window] static void requestPermission(optional NotificationPermissionCallback callback);
attribute EventHandler onclick;
attribute EventHandler onerror;
readonly attribute DOMString title;
readonly attribute NotificationDirection dir;
readonly attribute DOMString lang;
readonly attribute DOMString body;
readonly attribute DOMString tag;
readonly attribute USVString icon;
readonly attribute USVString sound;
void close();
};
var notification = new Notification("Pssssst! One Moment Here...!", {
icon: 'http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/256/Emblems-emblem-symbolic-link-icon.png',
body: 'Click to Launch The Site.'
});
In the light of the interface definition described above, this code produces a simple Notification with the specified title.
What must also be noted is that each notification publishes several events over its life time and allows the developer to register listeners for the same.
Consider how I have attached a "Click" listener on the Notification.
notification.onclick = function() {
window.open("http://ccscoder.solutioneducation.co.in");
};
In this case, I have opened a new website in a new window. In a similar fashion, you can attach listeners for "close" and other events too. For a complete list of events, refer to the Specification.
This is a very simple introduction to the Web Notifications API, which in no way should be treated as comprehensive. There is a whole section of the API that I have not touched upon namely the "Service Worker API" that is associated with the Notifications.
A few words of caution...
Cheers.