SOURCE

console 命令行工具 X clear

                    
>
console
function test() {
    if (Notification.permission == "granted") {
        var notification = new Notification("Hi,帅哥:", {
            body: '老师说:' + Math.random()
        });

        notification.onclick = function () {
           var a = 'xxx于' + new Date().toTimeString().split(' ')[0] + '点击!';
            console.log(a);
            notification.close();
        };
    }
}

window.setInterval(showalert, 1000);
function showalert() {
    console.log('123');
    test();
}


Notification.requestPermission(function (permission) {
    // if (permission === 'granted') {
    //     test()
    // }
})
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Web Notification API</title>
  </head>
  <body>

  
    测试
  </body>
</html>