首页 > 代码库 > 浏览器右下角提示(返回桌面还可以提示信息)

浏览器右下角提示(返回桌面还可以提示信息)

<a onclick="showNotification();">show Notification</a>
     
<script>
    function showNotification () {
        window.Notification.permission = "granted";
        alert(window.Notification.permission);
        if (window.Notification){
            if (window.Notification.permission == "granted") {
                var notification = new Notification(‘标题‘, {
                    body: "内容",
                    icon: "图标路径,若不指定默认为favicon"
                });
                setTimeout(function(){notification.close();},5000);
            } else {
                window.Notification.requestPermission();
            }    
        }else alert(‘你的浏览器不支持此消息提示功能,请使用chrome内核的浏览器!‘);
    };
</script>

浏览器右下角提示(返回桌面还可以提示信息)