Html5 / javascript desktop notifications

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Html5 / javascript desktop notifications

    with html5 and a decent web browser you can now create desktop notifications...
    so even if the browser is not in focus you can show things like: you have 1 new message :D

    heres a Demo: http://something-else.wen.su/notification.html
    and here is the script:
    PHP Code:
    <html>
    <head>
    <script type="text/javascript">
    
        //request permission
        function RequestPermission (callback)
        {
                window.webkitNotifications.requestPermission(callback);
        }
    
        //notify 
        function notification ()
        {
            if (!window.webkitNotifications)
            {
                alert('Get A Better Browser ;) Try Google Chrome');
                return;
            }
            if (window.webkitNotifications.checkPermission() > 0) {
                RequestPermission(notification);
            }
            var icon  = 'http://something-else.wen.su/icon.png';
            var title = 'New Message';
            var body   = 'You Have a new message :D';
            var popup = window.webkitNotifications.createNotification(icon, title, body);
            popup.show(); //open noticication
            setTimeout(function(){ //set timer
            popup.cancel(); //close noticication
            }, '15000'); //time of 15000 milliseconds
        }
    
        //html notify
        function htmlnotification ()
        {
            if (!window.webkitNotifications)
            {
                alert('Get A Better Browser ;) Try Google Chrome');
                return;
            }
            if (window.webkitNotifications.checkPermission() > 0) {
                RequestPermission(HTMLnotification);
            }
            var popup = window.webkitNotifications.createHTMLNotification('http://something-else.wen.su/');
            popup.show();  //open noticication
            setTimeout(function(){ //set timer
            popup.cancel(); //close popup
            }, '15000'); //time of 15000 milliseconds
        }
    
    </script>
    </head>
    <body>
    <button onclick="notification()">Create Notification</button><br/>
    <button onclick="htmlnotification()">Create html Notification</button><br/>
    </body>
    </html> 
    

    #2
    I like twitter bootstrip Its Makes every Perfert On html5
    May be You like dis
    jQuery notification Plug in

    developed by 9lessons.info
    Last edited by shushant; 10.05.12, 13:52.

    Comment

    Working...
    X