当前位置: 代码迷 >> HTML/CSS >> HTML5 Notification圆桌面提醒功能,html5 教程
  详细解决方案

HTML5 Notification圆桌面提醒功能,html5 教程

热度:828   发布时间:2013-01-27 13:56:15.0
HTML5 Notification桌面提醒功能,html5 教程
HTML5 Notification桌面提醒功能,html5 教程

<!DOCTYPE HTML>
<html>
<head
<meta charset="gbk">
<title>Creating OS notifications in HTML5</title>
</head>
<body>
<input type="button" value="验证授权" onclick="init();" />
<input type="button" value="弹出消息" onclick="notify();" />

const miao = 5;
function init(){
if (window.webkitNotifications) {
window.webkitNotifications.requestPermission();
}
}
function notify() {
if (window.webkitNotifications.checkPermission() == 0) {
var popup = window.webkitNotifications.createNotification("zencart.me.png", "http://zencart.me", " http://zencart.me/archives/905");
popup.ondisplay=(function(event){
setTimeout(function() {
event.currentTarget.cancel();
}, miao * 3000);
});
popup.show();
}else{
window.webkitNotifications.requestPermission();
}
}
HTML5 Notification桌面提醒功能,html5 教程 http://zencart.me/archives/905