Web Notification简单实现桌面消息通知(右下角提示)

js代码:

//新信息桌面右下角提示
function mesgNotice(){
    if(window.Notification && Notification.permission !== "denied") {
        Notification.requestPermission(function(status) {
            var notice_ = new Notification('新的消息', { body: '您有新的消息'}); 
            notice_.onclick = function() {//单击消息提示框,进入浏览器页面
                window.focus();
            }
        });
    }    
}

浏览器通知权限选择(请选允许)

效果图:

原文地址:https://www.cnblogs.com/ai211234/p/6409802.html