var notify = new Notification('通知标题', {body: '这里是通知内容!'}); notify.onclick = function () { //如果通知消息被点击,通知窗口将被激活 window.focus(); notify.close(); //打开对应的界面 }; notify.onerror = function () { console.log("HTML5桌面消息出错!!!"); }; notify.onclose = function () { console.log("HTML5桌面消息关闭!!!"); };