HTML5 Web Notification

HTML

<button onclick="notifyMe()">Notify me!</button>

JavaScript

closeHandler = function (event) {
    alert("It's late, I go...\n" + event);
    console.log(event);
};

function notifyMe() {
    // Let's check if the browser supports notifications
    console.log(Notification.permission)
    if (!("Notification" in window)) {
        alert("This browser does not support desktop notification");
    }

    // Let's check if the user is okay to get some notification
    else if (Notification.permission === "granted") {
        // If it's okay let's create a notification
        var notification = new Notification("Hi there!");
        notification.onclose = closeHandler;
    }

    // Otherwise, we need to ask the user for permission
    else if (Notification.permission == 'denied') {
    console.log('hgdhfh')
        Notification.requestPermission(function (permission) {
            // If the user is okay, let's create a notification
            
            if (permission == "granted") {
            console.log('permission',permission)
                var notification = new Notification("Hi there!");
               // notification.onclose = closeHandler;
            }
        });
    }

    // At last, if the user already denied any notification, and you 
    // want to be respectful there is no need to bother them any more.
}