Cấp bậc tác giả:

HTML

HTML5 Desktop Notification Tutorial

Được viết bởi QuangIT ngày 22/09/2012 lúc 11:27 AM
Desktop notification là một tính năng thú vị của HTML5. Websites của bạn có thể gửi notification ra ngoài màn hình desktop. Tuy nhiên, hiện tại nó chỉ hổ trợ trình duyệt google chrome. Mời các bạn xem demo
  • 0
  • 7536

HTML5 Desktop Notification Tutorial

Desktop notification là một tính năng thú vị của HTML5. Websites của bạn có thể gửi notification ra ngoài màn hình desktop. Tuy nhiên, hiện tại nó chỉ hổ trợ trình duyệt google chrome. Mời các bạn xem demo

DEMO


Code:


<html>

<title>Demo desktop notification javascript</title>

<head>

<script>


    if (!window.webkitNotifications) {

        alert('Sorry , your browser does not support desktop notification. Try Google Chrome.');

    }

        function RequestPermission (callback)

    {

        window.webkitNotifications.requestPermission(callback);

    }

    function notification ()

    {      

        if (window.webkitNotifications.checkPermission() > 0) {

            RequestPermission(notification);

        }


       

        var icon  = 'http://thienduongweb.com/logo.png';

        var title = 'BEAKKON';

        var body   = 'Flying he keeps his eyes on the stars';


     

        var popup = window.webkitNotifications.createNotification(icon, title, body);

        popup.show();

        setTimeout(function(){

        popup.cancel();

        }, '15000');

    }

   

    function HTMLnotification ()

    {

        if (window.webkitNotifications.checkPermission() > 0) {

            RequestPermission(HTMLnotification);

        }


       

        var popup = window.webkitNotifications.createHTMLNotification('http://www.thienduongweb.com');

        popup.show();

        setTimeout(function(){

        popup.cancel();

        }, '15000');

    }

</script>

</head>

<body>

<button onclick="notification()">NOTIFY</button>

<button onclick="HTMLnotification()">NOTIFY ME(HTML)</button>

</body>

</html>

Nguồn bài viết: Dngaz.com

BÌNH LUẬN BÀI VIẾT

Bài viết mới nhất

LIKE BOX

Bài viết được xem nhiều nhất

HỌC HTML